EasyManua.ls Logo

Espressif ESP32-S2 - Page 594

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
int httpd_socket_send(httpd_handle_t hd, int sockfd, const char *buf, size_t buf_len, int flags)
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 hd, int sockfd, char *buf, size_t buf_len, int flags)
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 handle, httpd_err_code_t error,
httpd_err_handler_func_t handler_fn)
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 *handle, const httpd_config_t *config)
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 583
Submit Document Feedback
Release v4.4

Table of Contents