Chapter 4. Software framework
Are there any limits on the maximum number of TCP client connection after the ESP32 additionally opens
the TCP server?
Yes. The number of simultaneously connected socket fd number for ESP32 is limited by
LWIP_MAX_SOCKETS, which is 10 by default.
What is the default MTU of lwIP for an ESP32?
The default MTU of lwIP is 1500. This is a xed value and it is not recommended to change it.
How to increase the DNS request time for ESP32?
You can manually modify the #define DNS_MAX_RETRIES 4 in esp-
idf/components/lwip/lwip/src/include/lwip/opt.h. For example, you can change the value of #define
DNS_MAX_RETRIES to 10. In this way, the maximum time that DNS waits for a response from the
server is 46 s (1+1+2+3+4+5+6+7+8+9).
After creating and closing TCP SOCKET several times, an error is reported as “Unable to create TCP
socket: errno 23”. How to resolve such issue?
:CHIP: ESP8266 | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 :
• Reason: “errno 23 ”means open many open les in system. Closing a socket takes 2 MSL of
time, which means sockets will not be closed immediately after calling the close interface. Due
to this reason, open sockets are accumulated and exceeds the maximum connection number (the
default is 10 in menucong, the maximum connection is 16) thus triggering this error.
• Solution: Set SO_LINGER via the setsockopt interface to adjust the TCP close time.
linger link ;
link.on_off = 1 ;
link.linger = 0 ;
setsockopt(m_sockConnect, SOL_SOCKET, SO_LINGER, (const char*)&link,␣
,→sizeof(linger));
What happens when ESP8266 receives a “tcp out of order”message?
• If CONFIG_LWIP_TCP_QUEUE_OOSEQ(Component config -> LWIP -> TCP -> Queue
incoming out-of-order segments) is enabled, the out-of-order messages will be stored at the cost
of memory consumption.
• If this conguration is disabled, after receiving the “out of order”message, data will be discarded and a
retransmission will be requested. For example, there are four data packets namely 1, 2, 3 and 4, ESP8266
receives 1 rst, and then receives 4. If this conguration is enabled, ESP8266 will store the data of 4, wait
until it receives 2, 3, and then report the four packets to the application layer; if this conguration is disabled,
ESP8266 will discard the packet of 4 when it receives it, and let the other side send packet 2, and then the
other side will send from 2. Under this condition, the retransmission is increased.
Espressif Systems 95
Submit Document Feedback
Release master