gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36730 - libmicrohttpd/src/examples


From: gnunet
Subject: [GNUnet-SVN] r36730 - libmicrohttpd/src/examples
Date: Sat, 5 Dec 2015 17:30:51 +0100

Author: grothoff
Date: 2015-12-05 17:30:51 +0100 (Sat, 05 Dec 2015)
New Revision: 36730

Added:
   libmicrohttpd/src/examples/timeout.c
Modified:
   libmicrohttpd/src/examples/Makefile.am
Log:
add timeout example

Modified: libmicrohttpd/src/examples/Makefile.am
===================================================================
--- libmicrohttpd/src/examples/Makefile.am      2015-12-04 13:06:18 UTC (rev 
36729)
+++ libmicrohttpd/src/examples/Makefile.am      2015-12-05 16:30:51 UTC (rev 
36730)
@@ -23,10 +23,11 @@
  dual_stack_example \
  minimal_example_comet \
  querystring_example \
+ timeout \
  fileserver_example \
  fileserver_example_dirs \
  fileserver_example_external_select \
- refuse_post_example 
+ refuse_post_example
 
 
 if ENABLE_HTTPS
@@ -61,6 +62,11 @@
 minimal_example_LDADD = \
  $(top_builddir)/src/microhttpd/libmicrohttpd.la
 
+timeout_SOURCES = \
+ timeout.c
+timeout_LDADD = \
+ $(top_builddir)/src/microhttpd/libmicrohttpd.la
+
 chunked_example_SOURCES = \
  chunked_example.c
 chunked_example_LDADD = \
@@ -156,5 +162,3 @@
  $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS)
 https_fileserver_example_LDADD = \
  $(top_builddir)/src/microhttpd/libmicrohttpd.la
-
-

Added: libmicrohttpd/src/examples/timeout.c
===================================================================
--- libmicrohttpd/src/examples/timeout.c                                (rev 0)
+++ libmicrohttpd/src/examples/timeout.c        2015-12-05 16:30:51 UTC (rev 
36730)
@@ -0,0 +1,50 @@
+#include <microhttpd.h>
+#include <stdio.h>
+#include <string.h>
+
+#define PORT 8080
+
+static int
+answer_to_connection(void *cls,
+                     struct MHD_Connection *connection,
+                     const char *url,
+                     const char *method,
+                     const char *version,
+                     const char *upload_data,
+                     size_t *upload_data_size,
+                     void **con_cls)
+{
+  const char *page = "<html><body>Hello world!</body></html>";
+  struct MHD_Response *response;
+  int ret;
+
+  response = MHD_create_response_from_buffer (strlen(page),
+                                              (void *) page,
+                                              MHD_RESPMEM_PERSISTENT);
+  MHD_add_response_header(response,
+                          MHD_HTTP_HEADER_CONTENT_TYPE,
+                          "text/html");
+  ret = MHD_queue_response (connection,
+                            MHD_HTTP_OK,
+                            response);
+  MHD_destroy_response(response);
+  return ret;
+}
+
+
+int main()
+{
+  struct MHD_Daemon *daemon;
+
+  daemon = MHD_start_daemon(// MHD_USE_SELECT_INTERNALLY |
+                            MHD_USE_THREAD_PER_CONNECTION, // if you comment 
this line, the problem dies
+                            PORT, NULL, NULL,
+                            &answer_to_connection, NULL,
+                            MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 3,
+                            MHD_OPTION_END);
+  if (NULL == daemon)
+    return 1;
+  getchar();
+  MHD_stop_daemon(daemon);
+  return 0;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]