From 0fb7e430d7fba2e619719061060fb7540bb464ca Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 24 Dec 2013 00:01:06 +0900 Subject: [PATCH] examples: Set TCP_NODELAY option --- examples/libevent-client.c | 4 ++++ examples/libevent-server.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/examples/libevent-client.c b/examples/libevent-client.c index 15afc31a..e62175a2 100644 --- a/examples/libevent-client.c +++ b/examples/libevent-client.c @@ -24,6 +24,7 @@ */ #include #include +#include #include #include @@ -310,7 +311,10 @@ static void eventcb(struct bufferevent *bev, short events, void *ptr) { http2_session_data *session_data = (http2_session_data*)ptr; if(events & BEV_EVENT_CONNECTED) { + int fd = bufferevent_getfd(bev); + int val = 1; fprintf(stderr, "Connected\n"); + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); initialize_nghttp2_session(session_data); send_client_connection_header(session_data); submit_request(session_data); diff --git a/examples/libevent-server.c b/examples/libevent-server.c index 6883329b..e04dde3a 100644 --- a/examples/libevent-server.c +++ b/examples/libevent-server.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -154,11 +155,13 @@ static http2_session_data* create_http2_session_data(app_context *app_ctx, http2_session_data *session_data; SSL *ssl; char host[NI_MAXHOST]; + int val = 1; ssl = create_ssl(app_ctx->ssl_ctx); session_data = malloc(sizeof(http2_session_data)); memset(session_data, 0, sizeof(http2_session_data)); session_data->app_ctx = app_ctx; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); session_data->bev = bufferevent_openssl_socket_new (app_ctx->evbase, fd, ssl, BUFFEREVENT_SSL_ACCEPTING,