/* * Performs the network I/O. */ static void exec_io(struct Connection *connection) { int rv; rv = spdylay_session_recv(connection->session); if(rv != 0) { diec("spdylay_session_recv", rv); } rv = spdylay_session_send(connection->session); if(rv != 0) { diec("spdylay_session_send", rv); } }
/* * Performs the network I/O. */ int spdy_exec_io(struct SPDY_Connection *connection) { int rv; rv = spdylay_session_recv(connection->session); if(rv != 0) { PRINT_INFO2("spdylay_session_recv %i", rv); return rv; } rv = spdylay_session_send(connection->session); if(rv != 0) PRINT_INFO2("spdylay_session_send %i", rv); return rv; }
static void run_spdylay_session_send(void) { spdylay_session *session; spdylay_session_callbacks callbacks; const char *nv[] = { ":host", "example.org", ":scheme", "https", NULL }; spdylay_data_provider data_prd; spdylay_settings_entry iv[2]; my_user_data ud; int rv; memset(&callbacks, 0, sizeof(spdylay_session_callbacks)); callbacks.send_callback = null_send_callback; callbacks.get_credential_ncerts = get_credential_ncerts; callbacks.get_credential_cert = get_credential_cert; callbacks.get_credential_proof = get_credential_proof; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = 64*1024; iv[0].settings_id = SPDYLAY_SETTINGS_UPLOAD_BANDWIDTH; iv[0].flags = SPDYLAY_ID_FLAG_SETTINGS_PERSIST_VALUE; iv[0].value = 256; iv[1].settings_id = SPDYLAY_SETTINGS_MAX_CONCURRENT_STREAMS; iv[1].flags = SPDYLAY_ID_FLAG_SETTINGS_NONE; iv[1].value = 100; rv = spdylay_session_client_new(&session, SPDYLAY_PROTO_SPDY3, &callbacks, &ud); if(rv != 0) { goto client_new_fail; } rv = spdylay_submit_request(session, 3, nv, &data_prd, NULL); if(rv != 0) { goto fail; } rv = spdylay_submit_syn_stream(session, SPDYLAY_CTRL_FLAG_NONE, 0, 3, nv, NULL); if(rv != 0) { goto fail; } rv = spdylay_session_send(session); if(rv != 0) { goto fail; } /* The SYN_STREAM submitted by the previous spdylay_submit_syn_stream will have stream ID 3. Send HEADERS to that stream. */ rv = spdylay_submit_headers(session, SPDYLAY_CTRL_FLAG_NONE, 3, nv); if(rv != 0) { goto fail; } rv = spdylay_submit_data(session, 3, SPDYLAY_DATA_FLAG_FIN, &data_prd); if(rv != 0) { goto fail; } rv = spdylay_session_send(session); if(rv != 0) { goto fail; } rv = spdylay_submit_rst_stream(session, 3, SPDYLAY_CANCEL); if(rv != 0) { goto fail; } rv = spdylay_session_send(session); if(rv != 0) { goto fail; } /* Sending against half-closed stream */ rv = spdylay_submit_headers(session, SPDYLAY_CTRL_FLAG_NONE, 3, nv); if(rv != 0) { goto fail; } rv = spdylay_submit_data(session, 3, SPDYLAY_DATA_FLAG_FIN, &data_prd); if(rv != 0) { goto fail; } rv = spdylay_submit_ping(session); if(rv != 0) { goto fail; } rv = spdylay_submit_settings(session, SPDYLAY_FLAG_SETTINGS_NONE, iv, 2); if(rv != 0) { goto fail; } rv = spdylay_session_send(session); if(rv != 0) { goto fail; } rv = spdylay_submit_goaway(session, SPDYLAY_GOAWAY_OK); if(rv != 0) { goto fail; } rv = spdylay_session_send(session); if(rv != 0) { goto fail; } fail: spdylay_session_del(session); client_new_fail: ; }