Commit 134a5b7b authored by Sergey Lyubka's avatar Sergey Lyubka

Using chunked API in multi-threaded example

parent d39daab2
......@@ -3,10 +3,10 @@
// Start a browser and hit refresh couple of times. The replies will
// come from both server instances.
static int request_handler(struct mg_connection *conn) {
mg_printf(conn, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n"
"This is a reply from server instance # %s",
(char *) conn->server_param);
return 1;
mg_send_header(conn, "Content-Type", "text/plain");
mg_printf_data(conn, "This is a reply from server instance # %s",
(char *) conn->server_param);
return 0;
}
static void *serve(void *server) {
......@@ -30,7 +30,8 @@ int main(void) {
// server1 goes to separate thread, server 2 runs in main thread.
// IMPORTANT: NEVER LET DIFFERENT THREADS HANDLE THE SAME SERVER.
mg_start_thread(serve, server1);
serve(server2);
mg_start_thread(serve, server2);
getchar();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment