make test client notice if server closed on him
Signed-off-by: Andy Green <andy@warmcat.com>
diff --git a/test-server/test-client.c b/test-server/test-client.c
index 52ce477..e887971 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -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 @@
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 @@
*/
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;