diff --git a/test-server/test-client.c b/test-server/test-client.c index 52ce477f..e8879718 100644 --- a/test-server/test-client.c +++ b/test-server/test-client.c @@ -29,6 +29,7 @@ #include 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;