libevent: možnost ukončení zasláním příkazu "exit"
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 19 Nov 2016 19:58:52 +0100
changeset 336f68b5e695df
parent 32 0eaa8735a083
child 34 117e8ff77326
libevent: možnost ukončení zasláním příkazu "exit"
c++/domain-socket-bridge/domain-socket-bridge.c
     1.1 --- a/c++/domain-socket-bridge/domain-socket-bridge.c	Sat Nov 19 19:53:12 2016 +0100
     1.2 +++ b/c++/domain-socket-bridge/domain-socket-bridge.c	Sat Nov 19 19:58:52 2016 +0100
     1.3 @@ -124,19 +124,19 @@
     1.4  	/* This callback is invoked when there is data to read on bev. */
     1.5  	struct evbuffer *input = bufferevent_get_input(bev);
     1.6  	struct evbuffer *output = bufferevent_get_output(bev);
     1.7 -	struct event_base *base = (event_base *) user_data;
     1.8 +	struct event_base *base = bufferevent_get_base(bev);
     1.9 +	;
    1.10  
    1.11  	size_t len = evbuffer_get_length(input);
    1.12  	char *data = (char*) malloc(len);
    1.13  	evbuffer_copyout(input, data, len);
    1.14  	printf("we got some data: %s\n", data);
    1.15  
    1.16 -	/*
    1.17  	if (memcmp(data, "exit\n", len) == 0) {
    1.18  		struct timeval delay = {2, 123};
    1.19 +		printf("Klient říká, že máme končit; ukončuji program během %ld sekund a %ld mikrosekund.\n", delay.tv_sec, delay.tv_usec);
    1.20  		event_base_loopexit(base, &delay);
    1.21  	}
    1.22 -	 */
    1.23  
    1.24  
    1.25  	evbuffer_add(output, "echo: ", 6);