Chapter 2. API Reference
int
httpd_socket_send(httpd_handle_t
A low level API to send data on a given socket
This internally calls the default send function, or the function registered by httpd_sess_set_send_override().
Note This API is not recommended to be used in any request handler. Use this only for advanced use cases,
wherein some asynchronous data is to be sent over a socket.
Return
• Bytes : The number of bytes sent successfully
• HTTPD_SOCK_ERR_INVALID : Invalid arguments
• HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket send()
• HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket send()
Parameters
• [in] hd: server instance
• [in] sockfd: session socket file descriptor
• [in] buf: buffer with bytes to send
• [in] buf_len: data size
• [in] flags: flags for the send() function
int
httpd_socket_recv(httpd_handle_t
A low level API to receive data from a given socket
This internally calls the default recv function, or the function registered by httpd_sess_set_recv_override().
Note This API is not recommended to be used in any request handler. Use this only for advanced use cases,
wherein some asynchronous communication is required.
Return
• Bytes : The number of bytes received successfully
• 0 : Buffer length parameter is zero / connection closed by peer
• HTTPD_SOCK_ERR_INVALID : Invalid arguments
• HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket recv()
• HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket recv()
Parameters
• [in] hd: server instance
• [in] sockfd: session socket file descriptor
• [in] buf: buffer with bytes to send
• [in] buf_len: data size
• [in] flags: flags for the send() function
esp_err_t httpd_register_err_handler(httpd_handle_t
Function for registering HTTP error handlers.
This function maps a handler function to any supported error code given by httpd_err_code_t. See
prototype httpd_err_handler_func_t above for details.
Return
• ESP_OK : handler registered successfully
• ESP_ERR_INVALID_ARG : invalid error code or server handle
Parameters
• [in] handle: HTTP server handle
• [in] error: Error type
• [in] handler_fn: User implemented handler function (Pass NULL to unset any previously set
handler)
esp_err_t httpd_start(httpd_handle_t
Starts the web server.
Create an instance of HTTP server and allocate memory/resources for it depending upon the specified config-
uration.
Example usage:
Espressif Systems
hd, int sockfd, const char *buf, size_t buf_len, int flags)
hd, int sockfd, char *buf, size_t buf_len, int flags)
httpd_err_handler_func_t
*handle, const
httpd_config_t
583
Submit Document Feedback
handle,
httpd_err_code_t
handler_fn)
*config)
error,
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?