Chapter 2. API Reference
• [in] handle: Handle to server returned by httpd_start
esp_err_t httpd_sess_trigger_close(httpd_handle_t handle, int sockfd)
Trigger an httpd session close externally.
Note Calling this API is only required in special circumstances wherein some application requires to close an
httpd client session asynchronously.
Return
• ESP_OK : On successfully initiating closure
• ESP_FAIL : Failure to queue work
• ESP_ERR_NOT_FOUND : Socket fd not found
• ESP_ERR_INVALID_ARG : Null arguments
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] sockfd: The socket descriptor of the session to be closed
esp_err_t httpd_sess_update_lru_counter(httpd_handle_t handle, int sockfd)
Update LRU counter for a given socket.
LRU Counters are internally associated with each session to monitor how recently a session exchanged traffic.
When LRU purge is enabled, if a client is requesting for connection but maximum number of sockets/sessions
is reached, then the session having the earliest LRU counter is closed automatically.
Updating the LRU counter manually prevents the socket from being purged due to the Least Recently Used
(LRU) logic, even though it might not have received traffic for some time. This is useful when all open sock-
ets/session are frequently exchanging traffic but the user specifically wants one of the sessions to be kept open,
irrespective of when it last exchanged a packet.
Note Calling this API is only necessary if the LRU Purge Enable option is enabled.
Return
• ESP_OK : Socket found and LRU counter updated
• ESP_ERR_NOT_FOUND : Socket not found
• ESP_ERR_INVALID_ARG : Null arguments
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] sockfd: The socket descriptor of the session for which LRU counter is to be updated
esp_err_t httpd_get_client_list(httpd_handle_t handle, size_t *fds, int *client_fds)
Returns list of current socket descriptors of active sessions.
Note Size of provided array has to be equal or greater then maximum number of opened sockets, configured
upon initialization with max_open_sockets field in httpd_config_t structure.
Return
• ESP_OK : Successfully retrieved session list
• ESP_ERR_INVALID_ARG : Wrong arguments or list is longer than provided array
Parameters
• [in] handle: Handle to server returned by httpd_start
• [inout] fds: In: Size of provided client_fds array Out: Number of valid client fds returned in
client_fds,
• [out] client_fds: Array of client fds
Structures
struct httpd_config
HTTP Server Configuration Structure.
Note Use HTTPD_DEFAULT_CONFIG() to initialize the configuration to a default value and then modify
only those fields that are specifically determined by the use case.
Espressif Systems 586
Submit Document Feedback
Release v4.4