1 /* Feel free to use this example code in any way 2 you see fit (Public Domain) */ 3 4 #include <sys/types.h> 5 #ifndef _WIN32 6 #include <sys/select.h> 7 #include <sys/socket.h> 8 #else 9 #include <winsock2.h> 10 #endif 11 #include <microhttpd.h> 12 #include <stdio.h> 13 14 #define PORT 8888 15 16 17 static int 18 print_out_key (void *cls, enum MHD_ValueKind kind, const char *key, 19 const char *value) 20 { 21 printf ("%s: %s\n", key, value); 22 return MHD_YES; 23 } 24 25 26 static int 27 answer_to_connection (void *cls, struct MHD_Connection *connection, 28 const char *url, const char *method, 29 const char *version, const char *upload_data, 30 size_t *upload_data_size, void **con_cls) 31 { 32 printf ("New %s request for %s using version %s\n", method, url, version); 33 34 MHD_get_connection_values (connection, MHD_HEADER_KIND, print_out_key, 35 NULL); 36 37 return MHD_NO; 38 } 39 40 41 int 42 main () 43 { 44 struct MHD_Daemon *daemon; 45 46 daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 47 &answer_to_connection, NULL, MHD_OPTION_END); 48 if (NULL == daemon) 49 return 1; 50 51 (void) getchar (); 52 53 MHD_stop_daemon (daemon); 54 return 0; 55 } 56