GNU libmicrohttpd  0.9.72
mhd_sockets.c File Reference

Implementation for sockets functions. More...

#include "mhd_sockets.h"
Include dependency graph for mhd_sockets.c:

Go to the source code of this file.

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_noninheritable_ (MHD_socket sock)
 
int MHD_socket_set_nodelay_ (MHD_socket sock, bool on)
 
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)
 

Detailed Description

Implementation for sockets functions.

Header for platform-independent sockets abstraction.

Author
Karlson2k (Evgeny Grin)
Karlson2k (Evgeny Grin)

Provides basic abstraction for sockets. Any functions can be implemented as macro on some platforms unless explicitly marked otherwise. Any function argument can be skipped in macro, so avoid variable modification in function parameters.

Definition in file mhd_sockets.c.

Function Documentation

◆ MHD_add_to_fd_set_()

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.

Parameters
fdfile descriptor to add to the set
setset to modify
max_fdmaximum value to potentially update
fd_setsizevalue of FD_SETSIZE
Returns
non-zero if succeeded, zero otherwise

Definition at line 371 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.

◆ MHD_socket_buffering_reset_()

int MHD_socket_buffering_reset_ ( MHD_socket  sock)

Change socket buffering mode to default.

Parameters
socksocket to manipulate
Returns
non-zero if succeeded, zero otherwise

Definition at line 552 of file mhd_sockets.c.

References MHD_socket_cork_(), and MHD_socket_set_nodelay_().

Here is the call graph for this function:

◆ MHD_socket_cork_()

int MHD_socket_cork_ ( MHD_socket  sock,
bool  on 
)

Enable/disable the cork option.

Parameters
socksocket to manipulate
onset to true to enable CORK, false to disable
Returns
non-zero if succeeded, zero otherwise

Definition at line 500 of file mhd_sockets.c.

References MHD_INVALID_SOCKET.

Referenced by MHD_socket_buffering_reset_().

Here is the caller graph for this function:

◆ MHD_socket_create_listen_()

MHD_socket MHD_socket_create_listen_ ( int  pf)

Create a listen socket, with noninheritable flag if possible.

Parameters
pfprotocol family to use
Returns
created socket or MHD_INVALID_SOCKET in case of errors

Definition at line 577 of file mhd_sockets.c.

References fd, MHD_INVALID_SOCKET, MHD_socket_close_, MHD_socket_fset_error_, MHD_socket_get_error_, MHD_socket_noninheritable_(), MSG_NOSIGNAL_OR_ZERO, NULL, SOCK_CLOEXEC_OR_ZERO, and SOCK_NOSIGPIPE_OR_ZERO.

Here is the call graph for this function:

◆ MHD_socket_nonblocking_()

int MHD_socket_nonblocking_ ( MHD_socket  sock)

Change socket options to be non-blocking.

Parameters
socksocket to manipulate
Returns
non-zero if succeeded, zero otherwise

Definition at line 401 of file mhd_sockets.c.

◆ MHD_socket_noninheritable_()

int MHD_socket_noninheritable_ ( MHD_socket  sock)

Change socket options to be non-inheritable.

Parameters
socksocket to manipulate
Returns
non-zero if succeeded, zero otherwise
Warning
Does not set socket error on W32.

Definition at line 436 of file mhd_sockets.c.

◆ MHD_socket_set_nodelay_()

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.

Parameters
socksocket to manipulate
onvalue to use
Returns
0 on success

Definition at line 471 of file mhd_sockets.c.

Referenced by MHD_socket_buffering_reset_().

Here is the caller graph for this function: