GNU libmicrohttpd  0.9.69
mhd_send.h File Reference

Implementation of send() wrappers. More...

#include "platform.h"
#include "internal.h"
#include <errno.h>
#include "mhd_sockets.h"
#include "connection.h"
Include dependency graph for mhd_send.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  MHD_SendSocketOptions { MHD_SSO_NO_CORK = 0, MHD_SSO_MAY_CORK = 1, MHD_SSO_HDR_CORK = 2 }
 

Functions

ssize_t MHD_send_on_connection_ (struct MHD_Connection *connection, const char *buffer, size_t buffer_size, enum MHD_SendSocketOptions options)
 
ssize_t MHD_send_on_connection2_ (struct MHD_Connection *connection, const char *header, size_t header_size, const char *buffer, size_t buffer_size)
 

Detailed Description

Implementation of send() wrappers.

Author
ng0

Definition in file mhd_send.h.

Enumeration Type Documentation

◆ MHD_SendSocketOptions

The enumeration of send socket options.

Enumerator
MHD_SSO_NO_CORK 

definitely no corking (use NODELAY, or explicitly disable cork)

MHD_SSO_MAY_CORK 

should enable corking (use MSG_MORE, or explicitly enable cork)

MHD_SSO_HDR_CORK 

consider tcpi_snd_mss and consider not corking for the header part if the size of the header is close to the MSS. Only used if we are NOT doing 100 Continue and are still sending the header (provided in full as the buffer to MHD_send_on_connection_ or as the header to MHD_send_on_connection2_).

Definition at line 59 of file mhd_send.h.

Function Documentation

◆ MHD_send_on_connection2_()

ssize_t MHD_send_on_connection2_ ( struct MHD_Connection connection,
const char *  header,
size_t  header_size,
const char *  buffer,
size_t  buffer_size 
)

Send header followed by buffer on connection. Uses writev if possible to send both at once and returns the sum of the number of bytes sent from both buffers, or -1 on error; if writev is unavailable, this call MUST only send from 'header' (as we cannot handle the case that the first write succeeds and the 2nd fails!).

Parameters
connectionthe MHD_Connection structure
headercontent of header to send
header_sizethe size of the header (in bytes)
buffercontent of the buffer to send
buffer_sizethe size of the buffer (in bytes)
Returns
sum of the number of bytes sent from both buffers or -1 on error

Definition at line 378 of file mhd_send.c.

References MHD_Connection::daemon, MAYBE_MSG_NOSIGNAL, MHD_send_on_connection_(), MHD_SSO_HDR_CORK, MHD_USE_TLS, MHD_Daemon::options, post_cork_setsockopt(), pre_cork_setsockopt(), MHD_Connection::sk_cork_on, and MHD_Connection::socket_fd.

Referenced by MHD_connection_handle_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_send_on_connection_()

ssize_t MHD_send_on_connection_ ( struct MHD_Connection connection,
const char *  buffer,
size_t  buffer_size,
enum MHD_SendSocketOptions  options 
)

Send buffer on connection, and remember the current state of the socket options; only call setsockopt when absolutely necessary.

Parameters
connectionthe MHD_Connection structure
buffercontent of the buffer to send
buffer_sizethe size of the buffer (in bytes)
optionsthe MHD_SendSocketOptions enum, MHD_SSO_NO_CORK: definitely no corking (use NODELAY, or explicitly disable cork), MHD_SSO_MAY_CORK: should enable corking (use MSG_MORE, or explicitly enable cork), MHD_SSO_HDR_CORK: consider tcpi_snd_mss and consider not corking for the header part if the size of the header is close to the MSS. Only used if we are NOT doing 100 Continue and are still sending the header (provided in full as the buffer to MHD_send_on_connection_ or as the header to MHD_send_on_connection2_).
Returns
sum of the number of bytes sent from both buffers or -1 on error

Definition at line 233 of file mhd_send.c.

References MHD_Connection::daemon, MAYBE_MSG_NOSIGNAL, MHD_CONNECTION_CLOSED, MHD_EPOLL_STATE_WRITE_READY, MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_ERR_NOTCONN_, MHD_INVALID_SOCKET, 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_SSO_HDR_CORK, MHD_SSO_MAY_CORK, MHD_SSO_NO_CORK, MHD_USE_TLS, MHD_Daemon::options, post_cork_setsockopt(), pre_cork_setsockopt(), MHD_Connection::sk_cork_on, MHD_Connection::socket_fd, SSIZE_MAX, and MHD_Connection::state.

Referenced by MHD_connection_handle_write(), and MHD_send_on_connection2_().

Here is the call graph for this function:
Here is the caller graph for this function: