GNU libmicrohttpd
0.9.69
|
Implementation of send() wrappers. More...
#include "platform.h"
#include "internal.h"
#include <errno.h>
#include "mhd_sockets.h"
#include "connection.h"
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) |
Implementation of send() wrappers.
Definition in file mhd_send.h.
The enumeration of send socket options.
Definition at line 59 of file mhd_send.h.
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!).
connection | the MHD_Connection structure |
header | content of header to send |
header_size | the size of the header (in bytes) |
buffer | content of the buffer to send |
buffer_size | the size of the buffer (in bytes) |
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().
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.
connection | the MHD_Connection structure |
buffer | content of the buffer to send |
buffer_size | the size of the buffer (in bytes) |
options | the 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_). |
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_().