Skip to content

Commit

Permalink
Update xkcp_util.c
Browse files Browse the repository at this point in the history
  • Loading branch information
liudf0716 authored Apr 19, 2017
1 parent 64e16ff commit beb77d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions xkcp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ void xkcp_set_config_param(ikcpcb *kcp)
param->sndwnd, param->rcvwnd, param->nodelay, param->interval, param->resend, param->nc);
}

static void set_tcp_no_delay(evutil_socket_t fd)
{
int one = 1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
&one, sizeof one);
}


void xkcp_tcp_event_cb(struct bufferevent *bev, short what, struct xkcp_task *task)
{
if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) {
Expand All @@ -184,6 +192,8 @@ void xkcp_tcp_event_cb(struct bufferevent *bev, short what, struct xkcp_task *ta
free(task);
}
bufferevent_free(bev);
} else if (what & BEV_EVENT_CONNECTED) {
set_tcp_no_delay(bufferevent_getfd(bev));
}
}

Expand Down

0 comments on commit beb77d2

Please sign in to comment.