GNU libmicrohttpd  0.9.72
connection_add.c File Reference

functions to add connection to our active set More...

Include dependency graph for connection_add.c:

Go to the source code of this file.

Macros

#define EXTRA_SLOTS   0
 

Functions

static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ thread_main_handle_connection (void *data)
 
static ssize_t recv_param_adapter (struct MHD_Connection *connection, void *other, size_t i)
 
static ssize_t send_param_adapter (struct MHD_Connection *connection, const void *other, size_t i)
 
static enum MHD_StatusCode internal_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen, bool external_add, bool non_blck)
 
enum MHD_StatusCode MHD_daemon_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
 
enum MHD_StatusCode MHD_accept_connection_ (struct MHD_Daemon *daemon)
 

Detailed Description

functions to add connection to our active set

Author
Christian Grothoff

Definition in file connection_add.c.

Macro Definition Documentation

◆ EXTRA_SLOTS

#define EXTRA_SLOTS   0

Function Documentation

◆ internal_add_connection()

static enum MHD_StatusCode internal_add_connection ( struct MHD_Daemon daemon,
MHD_socket  client_socket,
const struct sockaddr *  addr,
socklen_t  addrlen,
bool  external_add,
bool  non_blck 
)
static

Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client.

The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards.

Parameters
daemondaemon that manages the connection
client_socketsocket to manage (MHD will expect to receive an HTTP request from this socket next).
addrIP address of the client
addrlennumber of bytes in addr
external_addperform additional operations needed due to the application calling us directly
non_blckindicate that socket in non-blocking mode
Returns
#MHD_SC_OK on success

Definition at line 521 of file connection_add.c.

References MHD_EPOLL_STATE_WRITE_READY, MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_ERR_NOTCONN_, MHD_INVALID_SOCKET, MHD_REQUEST_CLOSED, MHD_SCKT_ECONNRESET_, MHD_SCKT_ERR_IS_, MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_EINTR_, MHD_SCKT_SEND_MAX_SIZE_, MHD_send_, MHD_socket_get_error_, MHD_Connection::request, MHD_Connection::socket_fd, and MHD_Request::state.

◆ MHD_accept_connection_()

enum MHD_StatusCode MHD_accept_connection_ ( struct MHD_Daemon daemon)

Accept an incoming connection and create the MHD_Connection object for it. This function also enforces policy by way of checking with the accept policy callback.

Remarks
To be called only from thread that process daemon's select()/poll()/etc.
Parameters
daemonhandle with the listen socket
Returns
#MHD_SC_OK on success

Definition at line 521 of file connection_add.c.

◆ recv_param_adapter()

static ssize_t recv_param_adapter ( struct MHD_Connection connection,
void *  other,
size_t  i 
)
static

Callback for receiving data from the socket.

Parameters
connectionthe MHD connection structure
otherwhere to write received data to
imaximum size of other (in bytes)
Returns
positive value for number of bytes actually received or negative value for error number MHD_ERR_xxx_

Definition at line 468 of file connection_add.c.

References MHD_EPOLL_STATE_READ_READY, MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_ERR_NOTCONN_, MHD_INVALID_SOCKET, MHD_recv_, MHD_REQUEST_CLOSED, MHD_SCKT_ECONNRESET_, MHD_SCKT_ERR_IS_, MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_EINTR_, MHD_SCKT_SEND_MAX_SIZE_, MHD_socket_get_error_, MHD_Connection::request, MHD_Connection::socket_fd, and MHD_Request::state.

◆ send_param_adapter()

static ssize_t send_param_adapter ( struct MHD_Connection connection,
const void *  other,
size_t  i 
)
static

Callback for writing data to the socket.

Parameters
connectionthe MHD connection structure
otherdata to write
inumber of bytes to write
Returns
positive value for number of bytes actually sent or negative value for error number MHD_ERR_xxx_

Definition at line 521 of file connection_add.c.

◆ thread_main_handle_connection()

static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ thread_main_handle_connection ( void *  data)
static