Skip to content

Commit

Permalink
Update xkcp_spy.c
Browse files Browse the repository at this point in the history
  • Loading branch information
liudf0716 authored Apr 18, 2017
1 parent 0b82ea4 commit c25347e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions xkcp_spy.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ static void timeoutcb(evutil_socket_t fd, short what, void *arg)
static void readcb(struct bufferevent *bev, void *ctx)
{
struct event_base *base = ctx;
/* This callback is invoked when there is data to read on bev. */
struct evbuffer *input = bufferevent_get_input(bev);
struct evbuffer *output = bufferevent_get_output(bev);

/* Copy all the data from the input buffer to the output buffer. */
evbuffer_add_buffer(output, input);
char buf[1024] = {0};
int len;

while ((len = evbuffer_remove(input, buf, sizeof(buf))) > 0) {
printf("%s", buf);
}
printf("\n");

event_base_loopexit(base, NULL);
}

Expand Down

0 comments on commit c25347e

Please sign in to comment.