examples: Set TCP_NODELAY option
This commit is contained in:
parent
4e01ed1a95
commit
0fb7e430d7
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
@ -310,7 +311,10 @@ static void eventcb(struct bufferevent *bev, short events, void *ptr)
|
||||||
{
|
{
|
||||||
http2_session_data *session_data = (http2_session_data*)ptr;
|
http2_session_data *session_data = (http2_session_data*)ptr;
|
||||||
if(events & BEV_EVENT_CONNECTED) {
|
if(events & BEV_EVENT_CONNECTED) {
|
||||||
|
int fd = bufferevent_getfd(bev);
|
||||||
|
int val = 1;
|
||||||
fprintf(stderr, "Connected\n");
|
fprintf(stderr, "Connected\n");
|
||||||
|
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
|
||||||
initialize_nghttp2_session(session_data);
|
initialize_nghttp2_session(session_data);
|
||||||
send_client_connection_header(session_data);
|
send_client_connection_header(session_data);
|
||||||
submit_request(session_data);
|
submit_request(session_data);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
@ -154,11 +155,13 @@ static http2_session_data* create_http2_session_data(app_context *app_ctx,
|
||||||
http2_session_data *session_data;
|
http2_session_data *session_data;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
char host[NI_MAXHOST];
|
char host[NI_MAXHOST];
|
||||||
|
int val = 1;
|
||||||
|
|
||||||
ssl = create_ssl(app_ctx->ssl_ctx);
|
ssl = create_ssl(app_ctx->ssl_ctx);
|
||||||
session_data = malloc(sizeof(http2_session_data));
|
session_data = malloc(sizeof(http2_session_data));
|
||||||
memset(session_data, 0, sizeof(http2_session_data));
|
memset(session_data, 0, sizeof(http2_session_data));
|
||||||
session_data->app_ctx = app_ctx;
|
session_data->app_ctx = app_ctx;
|
||||||
|
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
|
||||||
session_data->bev = bufferevent_openssl_socket_new
|
session_data->bev = bufferevent_openssl_socket_new
|
||||||
(app_ctx->evbase, fd, ssl,
|
(app_ctx->evbase, fd, ssl,
|
||||||
BUFFEREVENT_SSL_ACCEPTING,
|
BUFFEREVENT_SSL_ACCEPTING,
|
||||||
|
|
Loading…
Reference in New Issue