GNU libmicrohttpd 0.9.71
|
#include "mhd_options.h"
#include <errno.h>
#include <stdbool.h>
#include <fcntl.h>
#include <stddef.h>
#include "mhd_limits.h"
#include "sysfdsetsize.h"
Go to the source code of this file.
Typedefs | |
typedef int | MHD_socket |
typedef int | MHD_SCKT_OPT_BOOL_ |
typedef size_t | MHD_SCKT_SEND_SIZE_ |
Functions | |
int | MHD_add_to_fd_set_ (MHD_socket fd, fd_set *set, MHD_socket *max_fd, unsigned int fd_setsize) |
int | MHD_socket_nonblocking_ (MHD_socket sock) |
int | MHD_socket_set_nodelay_ (MHD_socket sock, bool on) |
int | MHD_socket_noninheritable_ (MHD_socket sock) |
int | MHD_socket_cork_ (MHD_socket sock, bool on) |
int | MHD_socket_buffering_reset_ (MHD_socket sock) |
MHD_socket | MHD_socket_create_listen_ (int pf) |
#define _MHD_SYS_DEFAULT_FD_SETSIZE get_system_fdsetsize_value () |
Definition at line 131 of file mhd_sockets.h.
#define MAYBE_MSG_NOSIGNAL 0 |
Definition at line 180 of file mhd_sockets.h.
#define MAYBE_SOCK_CLOEXEC 0 |
Definition at line 162 of file mhd_sockets.h.
#define MAYBE_SOCK_NONBLOCK 0 |
Definition at line 168 of file mhd_sockets.h.
#define MAYBE_SOCK_NOSIGPIPE 0 |
Definition at line 174 of file mhd_sockets.h.
#define MHD_INVALID_SOCKET (-1) |
Definition at line 150 of file mhd_sockets.h.
#define MHD_POSIX_SOCKETS 1 |
Definition at line 46 of file mhd_sockets.h.
#define MHD_recv_ | ( | s, | |
b, | |||
l | |||
) | ((ssize_t) recv ((s),(void*) (b),(MHD_SCKT_SEND_SIZE_) (l), 0)) |
MHD_recv_ is wrapper for system's recv()
s | the socket to use |
b | the buffer for data to receive |
l | the length of b |
Definition at line 297 of file mhd_sockets.h.
#define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_ | ( | fd, | |
pset, | |||
setsize | |||
) |
Add FD to fd_set with specified FD_SETSIZE.
fd | the fd to add |
pset | the valid pointer to fd_set. |
setsize | the value of FD_SETSIZE. |
Definition at line 346 of file mhd_sockets.h.
#define MHD_SCKT_EACCESS_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 513 of file mhd_sockets.h.
#define MHD_SCKT_EAGAIN_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 426 of file mhd_sockets.h.
#define MHD_SCKT_EBADF_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 478 of file mhd_sockets.h.
#define MHD_SCKT_ECONNABORTED_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 448 of file mhd_sockets.h.
#define MHD_SCKT_ECONNRESET_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 443 of file mhd_sockets.h.
#define MHD_SCKT_EFAUL_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 493 of file mhd_sockets.h.
#define MHD_SCKT_EINTR_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 438 of file mhd_sockets.h.
#define MHD_SCKT_EINVAL_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 488 of file mhd_sockets.h.
#define MHD_SCKT_EMFILE_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 458 of file mhd_sockets.h.
#define MHD_SCKT_ENETDOWN_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 518 of file mhd_sockets.h.
#define MHD_SCKT_ENFILE_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 463 of file mhd_sockets.h.
#define MHD_SCKT_ENOBUFS_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 473 of file mhd_sockets.h.
#define MHD_SCKT_ENOMEM_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 468 of file mhd_sockets.h.
#define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 498 of file mhd_sockets.h.
#define MHD_SCKT_ENOTCONN_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 453 of file mhd_sockets.h.
#define MHD_SCKT_ENOTSOCK_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 483 of file mhd_sockets.h.
#define MHD_SCKT_ENOTSUP_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 503 of file mhd_sockets.h.
#define MHD_SCKT_EOPNOTSUPP_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 508 of file mhd_sockets.h.
#define MHD_SCKT_ERR_IS_ | ( | err, | |
code | |||
) |
Check whether given socket error is equal to specified system native MHD_SCKT_E*_ code. If platform don't have specific error code, result is always boolean false.
Definition at line 635 of file mhd_sockets.h.
#define MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_ | ( | err | ) |
Check whether is given socket error is type of "incoming connection was disconnected before 'accept()' is called".
Definition at line 699 of file mhd_sockets.h.
#define MHD_SCKT_ERR_IS_EAGAIN_ | ( | err | ) | MHD_SCKT_ERR_IS_ ((err),MHD_SCKT_EAGAIN_) |
Check whether given socket error is equal to system's socket error codes for EAGAIN or EWOULDBLOCK.
Definition at line 667 of file mhd_sockets.h.
#define MHD_SCKT_ERR_IS_EINTR_ | ( | err | ) | MHD_SCKT_ERR_IS_ ((err),MHD_SCKT_EINTR_) |
Check whether given socket error is equal to system's socket error codes for EINTR.
Definition at line 658 of file mhd_sockets.h.
#define MHD_SCKT_ERR_IS_LOW_RESOURCES_ | ( | err | ) |
Check whether given socket error is any kind of "low resource" error.
Definition at line 680 of file mhd_sockets.h.
#define MHD_SCKT_ERR_IS_REMOTE_DISCNN_ | ( | err | ) |
Check whether is given socket error is type of "connection was terminated by remote side".
Definition at line 712 of file mhd_sockets.h.
#define MHD_SCKT_EWOULDBLOCK_ MHD_SCKT_MISSING_ERR_CODE_ |
Definition at line 433 of file mhd_sockets.h.
#define MHD_SCKT_FD_FITS_FDSET_ | ( | fd, | |
pset | |||
) |
Check whether FD can be added to fd_set with current FD_SETSIZE.
fd | the fd to check |
pset | the pointer to fd_set to check or NULL to check whether FD can be used with fd_sets. |
Definition at line 333 of file mhd_sockets.h.
#define MHD_SCKT_FD_FITS_FDSET_SETSIZE_ | ( | fd, | |
pset, | |||
setsize | |||
) |
Check whether FD can be added to fd_set with specified FD_SETSIZE.
fd | the fd to check |
pset | the pointer to fd_set to check or NULL to check whether FD can be used with fd_sets. |
setsize | the value of FD_SETSIZE. |
Definition at line 311 of file mhd_sockets.h.
#define MHD_SCKT_LAST_ERR_IS_ | ( | code | ) |
Check whether last socket error is equal to specified system native MHD_SCKT_E*_ code. If platform don't have specific error code, result is always boolean false.
Definition at line 647 of file mhd_sockets.h.
#define MHD_SCKT_MISSING_ERR_CODE_ 31450 |
Definition at line 418 of file mhd_sockets.h.
#define MHD_SCKT_SEND_MAX_SIZE_ SSIZE_MAX |
MHD_SCKT_SEND_MAX_SIZE_ is maximum send()/recv() size value.
Definition at line 246 of file mhd_sockets.h.
#define MHD_send_ | ( | s, | |
b, | |||
l | |||
) |
MHD_send_ is wrapper for system's send()
s | the socket to use |
b | the buffer with data to send |
l | the length of data in b |
Definition at line 285 of file mhd_sockets.h.
MHD_socket_close_(fd) close any FDs (non-W32) / close only socket FDs (W32). Note that on HP-UNIX, this function may leak the FD if errno is set to EINTR. Do not use HP-UNIX.
fd | descriptor to close |
Definition at line 262 of file mhd_sockets.h.
#define MHD_socket_close_chk_ | ( | fd | ) |
MHD_socket_close_chk_(fd) close socket and abort execution if error is detected.
fd | socket to close |
Definition at line 272 of file mhd_sockets.h.
#define MHD_SOCKET_DEFINED 1 |
Definition at line 156 of file mhd_sockets.h.
#define MHD_socket_fset_error_ | ( | err | ) | (errno = (err)) |
MHD_socket_fset_error_() set socket system native error code.
Definition at line 579 of file mhd_sockets.h.
#define MHD_socket_get_error_ | ( | ) | (errno) |
MHD_socket_error_ return system native error code for last socket error.
Definition at line 547 of file mhd_sockets.h.
#define MHD_socket_last_strerr_ | ( | ) | MHD_socket_strerr_ (MHD_socket_get_error_ ()) |
Definition at line 573 of file mhd_sockets.h.
#define MHD_socket_set_error_ | ( | err | ) | (errno = (err)) |
MHD_socket_set_error_() set socket system native error code to specified code or replacement code if specified code is not defined on system.
Definition at line 618 of file mhd_sockets.h.
#define MHD_socket_set_error_to_ENOMEM | ( | ) |
Set socket's error code to ENOMEM or equivalent if ENOMEM is not available on platform.
Definition at line 733 of file mhd_sockets.h.
#define MHD_socket_strerr_ | ( | err | ) | strerror ((err)) |
Definition at line 566 of file mhd_sockets.h.
#define MHD_socket_try_set_error_ | ( | err | ) |
MHD_socket_try_set_error_() set socket system native error code if specified code is defined on system.
Definition at line 592 of file mhd_sockets.h.
#define MHD_SYS_select_ | ( | n, | |
r, | |||
w, | |||
e, | |||
t | |||
) | select ((n),(r),(w),(e),(t)) |
Definition at line 360 of file mhd_sockets.h.
typedef int MHD_SCKT_OPT_BOOL_ |
MHD_SCKT_OPT_BOOL_ is type for bool parameters for setsockopt()/getsockopt()
Definition at line 227 of file mhd_sockets.h.
typedef size_t MHD_SCKT_SEND_SIZE_ |
MHD_SCKT_SEND_SIZE_ is type used to specify size for send and recv functions
Definition at line 237 of file mhd_sockets.h.
typedef int MHD_socket |
MHD_socket is type for socket FDs
Definition at line 149 of file mhd_sockets.h.
int MHD_add_to_fd_set_ | ( | MHD_socket | fd, |
fd_set * | set, | ||
MHD_socket * | max_fd, | ||
unsigned int | fd_setsize | ||
) |
Add fd to the set. If fd is greater than max_fd, set max_fd to fd.
fd | file descriptor to add to the set |
set | set to modify |
max_fd | maximum value to potentially update |
fd_setsize | value of FD_SETSIZE |
Definition at line 377 of file mhd_sockets.c.
References fd, MHD_INVALID_SOCKET, MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_, MHD_SCKT_FD_FITS_FDSET_SETSIZE_, and NULL.
Referenced by internal_get_fdset2(), MHD_daemon_get_fdset2(), MHD_daemon_select_(), MHD_get_fdset2(), MHD_select(), and thread_main_handle_connection().
int MHD_socket_buffering_reset_ | ( | MHD_socket | sock | ) |
Change socket buffering mode to default.
sock | socket to manipulate |
Definition at line 552 of file mhd_sockets.c.
References MHD_socket_cork_(), and MHD_socket_set_nodelay_().
Referenced by MHD_add_connection().
int MHD_socket_cork_ | ( | MHD_socket | sock, |
bool | on | ||
) |
Enable/disable the cork option.
TCP_NOPUSH has the same logic as MSG_MSG_MORE. The two are more or less equivalent by a source transformation (ie send(MSG_MORE) => "set TCP_NOPUSH + send() + clear TCP_NOPUSH". Both of them are really fairly "local", but TCP_NOPUSH has a notion of persistency that is entirely lacking in MSG_MORE. ... with TCP_NOPUSH you basically have to know what your last write is, and clear the bit before that write if you want to avoid bad latencies.
See also: https://yarchive.net/comp/linux/sendfile.html
sock | socket to manipulate |
on | set to true to enable CORK, false to disable |
Enable/disable the cork option.
sock | socket to manipulate |
on | set to true to enable CORK, false to disable |
Definition at line 500 of file mhd_sockets.c.
References MHD_INVALID_SOCKET.
Referenced by MHD_socket_buffering_reset_(), post_cork_setsockopt(), and pre_cork_setsockopt().
MHD_socket MHD_socket_create_listen_ | ( | int | pf | ) |
Create a listen socket, with noninheritable flag if possible.
pf | protocol family to use |
Definition at line 474 of file mhd_sockets.c.
References fd, MAYBE_MSG_NOSIGNAL, MAYBE_SOCK_CLOEXEC, MAYBE_SOCK_NOSIGPIPE, MHD_INVALID_SOCKET, MHD_socket_close_, MHD_socket_fset_error_, MHD_socket_get_error_, MHD_socket_noninheritable_(), and NULL.
Referenced by MHD_start_daemon_va(), and open_listen_socket().
int MHD_socket_nonblocking_ | ( | MHD_socket | sock | ) |
Change socket options to be non-blocking.
sock | socket to manipulate |
Definition at line 407 of file mhd_sockets.c.
Referenced by MHD_accept_connection(), MHD_accept_connection_(), MHD_add_connection(), MHD_daemon_add_connection(), MHD_daemon_start(), and MHD_start_daemon_va().
int MHD_socket_noninheritable_ | ( | MHD_socket | sock | ) |
Change socket options to be non-inheritable.
sock | socket to manipulate |
Definition at line 442 of file mhd_sockets.c.
Referenced by MHD_accept_connection(), MHD_accept_connection_(), MHD_add_connection(), MHD_daemon_add_connection(), and MHD_socket_create_listen_().
int MHD_socket_set_nodelay_ | ( | MHD_socket | sock, |
bool | on | ||
) |
Disable Nagle's algorithm on sock. This is what we do by default for all TCP sockets in MHD, unless the platform does not support the MSG_MORE or MSG_CORK or MSG_NOPUSH options.
sock | socket to manipulate |
on | value to use |
Definition at line 471 of file mhd_sockets.c.
Referenced by MHD_accept_connection(), MHD_socket_buffering_reset_(), post_cork_setsockopt(), and pre_cork_setsockopt().