From de214bf8fa27227b3cd47f8f04da99d4480075a2 Mon Sep 17 00:00:00 2001 From: bel Date: Fri, 2 Oct 2015 21:02:01 +0200 Subject: [PATCH] Add more comments to embedded_c example --- examples/embedded_c/embedded_c.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/embedded_c/embedded_c.c b/examples/embedded_c/embedded_c.c index 0652fa21..14f32257 100644 --- a/examples/embedded_c/embedded_c.c +++ b/examples/embedded_c/embedded_c.c @@ -4,14 +4,16 @@ * License http://opensource.org/licenses/mit-license.php MIT License */ -/* Simple example program on how to use Embedded C interface. */ +/* Simple example program on how to use CivetWeb embedded into a C program. */ #ifdef _WIN32 #include #else #include #endif +#include #include + #include "civetweb.h" @@ -66,6 +68,7 @@ int ExampleHandler(struct mg_connection *conn, void *cbdata) int ExitHandler(struct mg_connection *conn, void *cbdata) { mg_printf(conn, "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n"); + mg_printf(conn, "Server will shut down.\n"); mg_printf(conn, "Bye!\n"); exitNow = 1; return 1; @@ -171,9 +174,12 @@ int WebSocketStartHandler(struct mg_connection *conn, void *cbdata) #ifdef USE_WEBSOCKET -#define MAX_WS_CLIENTS \ - 5 /* just for the test: a small number that can be reached */ - /* a real server should use a much higher number here */ +/* MAX_WS_CLIENTS defines how many clients can connect to a websocket at the + * same time. The value 5 is very small and used here only for demonstration; + * it can be easily tested to connect more than MAX_WS_CLIENTS clients. + * A real server should use a much higher number, or better use a dynamic list + * of currently connected websocket clients. */ +#define MAX_WS_CLIENTS (5) struct t_ws_client { struct mg_connection *conn;