Chapter 4. Software framework
What is the maximum length for each data transmission in the ESP-IDF lwIP?
If you are using the socket interface send, the maximum length supported is determined by the
SSIZE_MAX parameter. If you use the tcp_write function, the maximum length is limited by
snd_buf
(send buer length).
send
is a socket interface wrapped by lwIP based on the sequential
API, which is a higher-level interface than tcp_write and is more suitable for user-level calls. There
is basically no dierence in resource usage between the two API calls.
If I need more debug logs for lwIP layer related issues with ESP-IDF, how can I enable the corresponding
debug log to be printed (e.g. DHCP, IP)?
• To print lwIP-related debug log, open menucong, go to Component config -> LWIP, and enable the
option Enable LWIP Debug. There are sub-options, including Enable IP debug messages and
Enable DHCP debug messages. You could enable them as needed.
• If you don’t nd the desired debug log module in the above menucong, such as, UDP module, rst check
if there is #define UDP_DEBUG in esp-idf/components/lwip/port/esp32/include/
lwipopts.h. If yes, change #define UDP_DEBUG LWIP_DBG_OFF to #define UDP_DEBUG
LWIP_DBG_ON manually. If no, add #define UDP_DEBUG LWIP_DBG_ON to esp-idf/
components/lwip/port/esp32/include/lwipopts.h referring to #define UDP_DEBUG
LWIP_DBG_OFF in esp-idf/components/lwip/lwip/src/include/lwip/opt.h le.
What is the dierence between socket blocking and non-blocking in ESP-IDF?
• For reads, the dierence is whether the read interface returns immediately when no data arrives at the bottom.
A blocking read will wait until data has arrived or until an exception occurs, while a non-blocking read will
return immediately with or without data.
• For writes, the dierence is whether the write interface returns immediately when the underlying buer is
full. For blocking write, if the underlying buer is not writable (the underlying buer is full or the peer has
not acknowledged the previously sent data), the write operation will keep blocking until it is writable or an
exception occurs. For non-blocking write, it will write as much as it can without waiting for the underlying
buer to be writable or the length of the write to be returned.
• The non-blocking interface call does not block the current process, while the blocking interface does.
Can ESP32 use the IP of the previous successful connection for communication after connecting to the router,
and in case of failure, re-enter the authentication process and use DHCP to obtain a new IP?
• Yes, if you enable Component config -> LWIP ->DHCP: Restore last IP obtained from
DHCP server option in menucong.
• Note that you cannot use a static IP instead, because static IP settings do not have conict detection. It may
lead to IP conict.
How do I achieve connect_timeout when programming with sockets?
• If you set the socket to the non-blocking mode, the connect() function will also be non-blocking. Then you can
set the timeout by the select() function to determine whether the socket is connected successfully or not. For
details, please refer to “connect_timeout settings of sockets”.
Espressif Systems 98
Submit Document Feedback
Release master