Civetweb API Reference

mg_write( conn, buf, len );

Parameters

ParameterTypeDescription
connstruct mg_connection *A pointer to the connection to be used to send data
bufconst void *A pointer to the blob of information to be sent
lensize_tThe amount of bytes to be sent

Return Value

TypeDescription
intAn integer indicating the amount of bytes sent, or failure

Description

The function mg_write() can be used to send a blob of arbitrary data over a connection. The size of the data is provided as a parameter. The only length limitation on this function is MAX_INT, because the return value of this function will turn negative with larger blocks of data, although they may have been sent correctly. The function returns the amount of bytes sent in case of success, the value 0 when the connection has been closed, and -1 in case of an error.

See Also