1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

make test client notice if server closed on him

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2011-02-14 20:25:43 +00:00
parent be93fefa76
commit b3ae0a36af

View file

@ -29,6 +29,7 @@
#include <poll.h>
static unsigned int opts;
static int was_closed;
/*
* This demo shows how to connect multiple websockets simultaneously to a
@ -91,6 +92,11 @@ callback_lws_mirror(struct libwebsocket_context * this,
switch (reason) {
case LWS_CALLBACK_CLOSED:
fprintf(stderr, "LWS_CALLBACK_CLOSED\n");
was_closed = 1;
break;
case LWS_CALLBACK_CLIENT_ESTABLISHED:
/*
@ -256,9 +262,11 @@ int main(int argc, char **argv)
*/
n = 0;
while (n >= 0)
while (n >= 0 && !was_closed)
n = libwebsocket_service(context, 1000);
fprintf(stderr, "Exiting\n");
libwebsocket_context_destroy(context);
return 0;