#include #include static enum MHD_Result httpd_handler (void *cls, struct MHD_Connection *conn, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) { struct MHD_Response *response; enum MHD_Result ret; static char resp[] = "Response text"; if (NULL == *con_cls) { *con_cls = "not null"; return MHD_YES; } response = MHD_create_response_from_buffer (sizeof (resp) - 1, resp, MHD_RESPMEM_PERSISTENT); MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/plain"); ret = MHD_queue_response (conn, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char **argv) { struct MHD_Daemon *mhd; int port = 8080; sigset_t sigs; int i; mhd = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, httpd_handler, NULL, MHD_OPTION_END); sigfillset (&sigs); sigwait (&sigs, &i); MHD_stop_daemon (mhd); return 0; }