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 15, 2017
1 parent 6c7f295 commit 11815ca
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions xkcp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,31 +189,14 @@ void xkcp_tcp_event_cb(struct bufferevent *bev, short what, struct xkcp_task *ta

void xkcp_tcp_read_cb(struct bufferevent *bev, ikcpcb *kcp)
{
#if 0
struct evbuffer *src;
size_t len;

src = bufferevent_get_input(bev);
len = evbuffer_get_length(src);

if (len > 0) {
char *data = malloc(len);
memset(data, 0, len);
evbuffer_copyout(src, data, len);
evbuffer_drain(src, len);
debug(LOG_INFO, "conv [%d] read data from client [%d]", kcp->conv, len);
ikcp_send(kcp, data, len);
free(data);
}
#else
char buf[1024] = {0};
int len, nret;
struct evbuffer *input = bufferevent_get_input(bev);
while ((len = evbuffer_remove(input, buf, sizeof(buf))) > 0) {
nret = ikcp_send(kcp, buf, len);
debug(LOG_INFO, "conv [%d] read data from client [%d] ikcp_send [%d]", kcp->conv, len, nret);
}
#endif

}


Expand Down

0 comments on commit 11815ca

Please sign in to comment.