aboutsummaryrefslogtreecommitdiff
path: root/src/examples/dual_stack_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/dual_stack_example.c')
-rw-r--r--src/examples/dual_stack_example.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/examples/dual_stack_example.c b/src/examples/dual_stack_example.c
index 31b25438..ffacec4a 100644
--- a/src/examples/dual_stack_example.c
+++ b/src/examples/dual_stack_example.c
@@ -25,7 +25,8 @@
25#include "platform.h" 25#include "platform.h"
26#include <microhttpd.h> 26#include <microhttpd.h>
27 27
28#define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" 28#define PAGE \
29 "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>"
29 30
30static int 31static int
31ahc_echo (void *cls, 32ahc_echo (void *cls,
@@ -39,23 +40,23 @@ ahc_echo (void *cls,
39 const char *me = cls; 40 const char *me = cls;
40 struct MHD_Response *response; 41 struct MHD_Response *response;
41 int ret; 42 int ret;
42 (void)url; /* Unused. Silent compiler warning. */ 43 (void) url; /* Unused. Silent compiler warning. */
43 (void)version; /* Unused. Silent compiler warning. */ 44 (void) version; /* Unused. Silent compiler warning. */
44 (void)upload_data; /* Unused. Silent compiler warning. */ 45 (void) upload_data; /* Unused. Silent compiler warning. */
45 (void)upload_data_size; /* Unused. Silent compiler warning. */ 46 (void) upload_data_size; /* Unused. Silent compiler warning. */
46 47
47 if (0 != strcmp (method, "GET")) 48 if (0 != strcmp (method, "GET"))
48 return MHD_NO; /* unexpected method */ 49 return MHD_NO; /* unexpected method */
49 if (&aptr != *ptr) 50 if (&aptr != *ptr)
50 { 51 {
51 /* do never respond on first call */ 52 /* do never respond on first call */
52 *ptr = &aptr; 53 *ptr = &aptr;
53 return MHD_YES; 54 return MHD_YES;
54 } 55 }
55 *ptr = NULL; /* reset when done */ 56 *ptr = NULL; /* reset when done */
56 response = MHD_create_response_from_buffer (strlen (me), 57 response = MHD_create_response_from_buffer (strlen (me),
57 (void *) me, 58 (void *) me,
58 MHD_RESPMEM_PERSISTENT); 59 MHD_RESPMEM_PERSISTENT);
59 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 60 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
60 MHD_destroy_response (response); 61 MHD_destroy_response (response);
61 return ret; 62 return ret;
@@ -68,15 +69,16 @@ main (int argc, char *const *argv)
68 struct MHD_Daemon *d; 69 struct MHD_Daemon *d;
69 70
70 if (argc != 2) 71 if (argc != 2)
71 { 72 {
72 printf ("%s PORT\n", argv[0]); 73 printf ("%s PORT\n", argv[0]);
73 return 1; 74 return 1;
74 } 75 }
75 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_DUAL_STACK, 76 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
76 atoi (argv[1]), 77 | MHD_USE_DUAL_STACK,
77 NULL, NULL, &ahc_echo, PAGE, 78 atoi (argv[1]),
78 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, 79 NULL, NULL, &ahc_echo, PAGE,
79 MHD_OPTION_END); 80 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120,
81 MHD_OPTION_END);
80 (void) getc (stdin); 82 (void) getc (stdin);
81 MHD_stop_daemon (d); 83 MHD_stop_daemon (d);
82 return 0; 84 return 0;