Browse Source

Add more comments to embedded_c example

bel 9 years ago
parent
commit
de214bf8fa
1 changed files with 10 additions and 4 deletions
  1. 10 4
      examples/embedded_c/embedded_c.c

+ 10 - 4
examples/embedded_c/embedded_c.c

@@ -4,14 +4,16 @@
 * License http://opensource.org/licenses/mit-license.php MIT License
 * 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
 #ifdef _WIN32
 #include <Windows.h>
 #include <Windows.h>
 #else
 #else
 #include <unistd.h>
 #include <unistd.h>
 #endif
 #endif
 
 
+#include <stdlib.h>
 #include <string.h>
 #include <string.h>
+
 #include "civetweb.h"
 #include "civetweb.h"
 
 
 
 
@@ -66,6 +68,7 @@ int ExampleHandler(struct mg_connection *conn, void *cbdata)
 int ExitHandler(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, "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");
 	mg_printf(conn, "Bye!\n");
 	exitNow = 1;
 	exitNow = 1;
 	return 1;
 	return 1;
@@ -171,9 +174,12 @@ int WebSocketStartHandler(struct mg_connection *conn, void *cbdata)
 
 
 #ifdef USE_WEBSOCKET
 #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 t_ws_client {
 	struct mg_connection *conn;
 	struct mg_connection *conn;