Functions | |
struct MHD_Daemon * | MHD_start_daemon_va (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap) |
struct MHD_Daemon * | MHD_start_daemon (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...) |
void | MHD_stop_daemon (struct MHD_Daemon *daemon) |
int | MHD_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *max_fd) |
int | MHD_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout) |
int | MHD_run (struct MHD_Daemon *daemon) |
int | MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) |
MHD API to start and stop the HTTP server and manage the event loop.
int MHD_get_fdset | ( | struct MHD_Daemon * | daemon, | |
fd_set * | read_fd_set, | |||
fd_set * | write_fd_set, | |||
fd_set * | except_fd_set, | |||
int * | max_fd | |||
) |
Obtain the `select()` sets for this daemon.
daemon | daemon to get sets from | |
read_fd_set | read set | |
write_fd_set | write set | |
except_fd_set | except set | |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
Definition at line 583 of file daemon.c.
References add_to_fd_set(), MHD_Daemon::connections_head, MHD_Connection::event_loop_info, MHD_EVENT_LOOP_INFO_BLOCK, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_EVENT_LOOP_INFO_READ, MHD_EVENT_LOOP_INFO_WRITE, MHD_NO, MHD_USE_EPOLL_LINUX_ONLY, MHD_USE_POLL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Connection::next, NULL, MHD_Daemon::options, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Daemon::shutdown, MHD_Connection::socket_fd, and MHD_Daemon::socket_fd.
Referenced by MHD_select().
int MHD_get_timeout | ( | struct MHD_Daemon * | daemon, | |
MHD_UNSIGNED_LONG_LONG * | timeout | |||
) |
Obtain timeout value for `select()` for this daemon (only needed if connection timeout is used). The returned value is how long `select()` or `poll()` should at most block, not the timeout value set for connections. This function MUST NOT be called if MHD is running with MHD_USE_THREAD_PER_CONNECTION.
daemon | daemon to query for timeout | |
timeout | set to the timeout (in milliseconds) |
Definition at line 1854 of file daemon.c.
References MHD_Connection::connection_timeout, MHD_Connection::last_activity, MHD_Daemon::manual_timeout_head, MHD_monotonic_time(), MHD_NO, MHD_USE_SSL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Connection::nextX, MHD_Daemon::normal_timeout_head, NULL, and MHD_Daemon::options.
Referenced by MHD_select().
int MHD_run | ( | struct MHD_Daemon * | daemon | ) |
Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used.
This function is a convenience method, which is useful if the fd_sets from MHD_get_fdset were not directly passed to `select()`; with this function, MHD will internally do the appropriate `select()` call itself again. While it is always safe to call MHD_run (in external select mode), you should call MHD_run_from_select if performance is important (as it saves an expensive call to `select()`).
daemon | daemon to run |
Definition at line 2584 of file daemon.c.
References MHD_cleanup_connections(), MHD_NO, MHD_poll(), MHD_select(), MHD_USE_EPOLL_LINUX_ONLY, MHD_USE_POLL, MHD_USE_SELECT_INTERNALLY, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Daemon::options, and MHD_Daemon::shutdown.
Referenced by MHD_run_from_select().
int MHD_run_from_select | ( | struct MHD_Daemon * | daemon, | |
const fd_set * | read_fd_set, | |||
const fd_set * | write_fd_set, | |||
const fd_set * | except_fd_set | |||
) |
Run webserver operations. This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used.
You can use this function instead of MHD_run if you called `select()` on the result from MHD_get_fdset. File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of MHD_run is more efficient as MHD will not have to call `select()` again to determine which operations are ready.
daemon | daemon to run select loop for | |
read_fd_set | read set | |
write_fd_set | write set | |
except_fd_set | except set (not used, can be NULL) |
Definition at line 1943 of file daemon.c.
References MHD_Daemon::connections_head, MHD_Connection::event_loop_info, MHD_Connection::idle_handler, MHD_accept_connection(), MHD_cleanup_connections(), MHD_EVENT_LOOP_INFO_BLOCK, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_EVENT_LOOP_INFO_READ, MHD_EVENT_LOOP_INFO_WRITE, MHD_NO, MHD_run(), MHD_USE_EPOLL_LINUX_ONLY, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Connection::next, NULL, MHD_Daemon::options, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_handler, MHD_Connection::socket_fd, MHD_Daemon::socket_fd, MHD_Daemon::wpipe, and MHD_Connection::write_handler.
Referenced by MHD_select().
struct MHD_Daemon * MHD_start_daemon | ( | unsigned int | flags, | |
uint16_t | port, | |||
MHD_AcceptPolicyCallback | apc, | |||
void * | apc_cls, | |||
MHD_AccessHandlerCallback | dh, | |||
void * | dh_cls, | |||
... | ||||
) | [read] |
Start a webserver on the given port. Variadic version of MHD_start_daemon_va.
flags | combination of `enum MHD_FLAG` values | |
port | port to bind to | |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted | |
apc_cls | extra argument to apc | |
dh | handler called for all requests (repeatedly) | |
dh_cls | extra argument to dh |
Start a webserver on the given port. Variadic version of MHD_start_daemon_va.
flags | combination of `enum MHD_FLAG` values | |
port | port to bind to | |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted | |
apc_cls | extra argument to apc | |
dh | handler called for all requests (repeatedly) | |
dh_cls | extra argument to dh |
Definition at line 2656 of file daemon.c.
References MHD_start_daemon_va().
struct MHD_Daemon * MHD_start_daemon_va | ( | unsigned int | flags, | |
uint16_t | port, | |||
MHD_AcceptPolicyCallback | apc, | |||
void * | apc_cls, | |||
MHD_AccessHandlerCallback | dh, | |||
void * | dh_cls, | |||
va_list | ap | |||
) | [read] |
Start a webserver on the given port.
flags | combination of `enum MHD_FLAG` values | |
port | port to bind to (in host byte order) | |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted | |
apc_cls | extra argument to apc | |
dh | handler called for all requests (repeatedly) | |
dh_cls | extra argument to dh | |
ap | list of options (type-value pairs, terminated with MHD_OPTION_END). |
Start a webserver on the given port.
flags | combination of `enum MHD_FLAG` values | |
port | port to bind to (in host byte order) | |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted | |
apc_cls | extra argument to apc | |
dh | handler called for all requests (repeatedly) | |
dh_cls | extra argument to dh | |
ap | list of options (type-value pairs, terminated with MHD_OPTION_END). |
Definition at line 3184 of file daemon.c.
References MHD_Daemon::apc, MHD_Daemon::apc_cls, MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::connection_timeout, create_socket(), create_thread(), MHD_Daemon::default_handler, MHD_Daemon::default_handler_cls, MHD_Daemon::master, MHD_Daemon::max_connections, MHD_BUF_INC_SIZE, MHD_http_unescape(), MHD_MAX_CONNECTIONS_DEFAULT, MHD_PANIC, MHD_POOL_SIZE_DEFAULT, MHD_select_thread(), MHD_stop_daemon(), MHD_USE_DEBUG, MHD_USE_DUAL_STACK, MHD_USE_EPOLL_LINUX_ONLY, MHD_USE_EPOLL_TURBO, MHD_USE_IPv6, MHD_USE_NO_LISTEN_SOCKET, MHD_USE_PIPE_FOR_SHUTDOWN, MHD_USE_POLL, MHD_USE_SELECT_INTERNALLY, MHD_USE_SSL, MHD_USE_SUSPEND_RESUME, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Daemon::options, parse_options_va(), MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, MHD_Daemon::pool_increment, MHD_Daemon::pool_size, MHD_Daemon::port, MHD_Daemon::socket_fd, MHD_Daemon::unescape_callback, MHD_Daemon::worker_pool, MHD_Daemon::worker_pool_size, and MHD_Daemon::wpipe.
Referenced by MHD_start_daemon().
void MHD_stop_daemon | ( | struct MHD_Daemon * | daemon | ) |
Shutdown an HTTP daemon.
daemon | daemon to stop |
Definition at line 3929 of file daemon.c.
References MHD_Daemon::cleanup_connection_mutex, close_all_connections(), MHD_PANIC, MHD_USE_EPOLL_LINUX_ONLY, MHD_USE_SELECT_INTERNALLY, MHD_USE_SSL, MHD_USE_SUSPEND_RESUME, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Daemon::options, MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, MHD_Daemon::shutdown, MHD_Daemon::socket_fd, MHD_Daemon::worker_pool, MHD_Daemon::worker_pool_size, and MHD_Daemon::wpipe.
Referenced by MHD_start_daemon_va().