Next: , Previous: , Up: Top   [Contents][Index]


6 Implementing external select

Function: enum MHD_Result 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. The daemon’s socket is added to read_fd_set. The list of currently existent connections is scanned and their file descriptors added to the correct set.

When calling this function, FD_SETSIZE is assumed to be platform’s default. If you changed FD_SETSIZE for your application, you should use MHD_get_fdset2() instead.

This function should only be called in when MHD is configured to use external select with select() or with epoll(). In the latter case, it will only add the single epoll() file descriptor used by MHD to the sets.

After the call completed successfully: the variable referenced by max_fd references the file descriptor with highest integer identifier. The variable must be set to zero before invoking this function.

Return MHD_YES on success, MHD_NO if: the arguments are invalid (example: NULL pointers); this daemon was not started with the right options for this call.

Function: enum MHD_Result MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set * read_fd_set, fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd, unsigned int fd_setsize)

Like MHD_get_fdset(), except that you can manually specify the value of FD_SETSIZE used by your application.

Function: enum MHD_Result MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout)

Obtain timeout value for select for this daemon (only needed if connection timeout is used). The returned value is how many milliseconds select should at most block, not the timeout value set for connections. This function must not be called if the MHD_USE_THREAD_PER_CONNECTION mode is in use (since then it is not meaningful to ask for a timeout, after all, there is concurrenct activity). The function must also not be called by user-code if MHD_USE_INTERNAL_POLLING_THREAD is in use. In the latter case, the behavior is undefined.

daemon

which daemon to obtain the timeout from.

timeout

will be set to the timeout (in milliseconds).

Return MHD_YES on success, MHD_NO if timeouts are not used (or no connections exist that would necessitate the use of a timeout right now).


Next: , Previous: , Up: Top   [Contents][Index]