Socket outgoing buffer overflow

Posts: 4
Joined: Fri Feb 16, 2018 6:05 pm

Socket outgoing buffer overflow

Postby stubb0rn » Sun Feb 18, 2018 2:05 pm

Hi folks

I'm currently working on a project that involves streaming data over the wifi. I implemented a library/component and am currently testing it. While doing so I encountered a strange behavior: Once my packets exceed a certain size, the EPS seems not to be able to send all data out as fast as they arrive and the internal buffer (?) runs over, producing a socket error.

From what I understood from the menuconfig help texts in the LWIP menu I guess it has something to do with insufficient memory but I couln't find any good documentation/references to understand the whole path from my application to the WiFi modem and would ask for anyone who has some readings on that, to share them.


User avatar
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Socket outgoing buffer overflow

Postby kolban » Mon Feb 19, 2018 4:48 am

I would have imagined that a call to send() to transmit data outbound from an ESP32 would block if it didn't have enough buffer space to accept a copy of the data to transmit. If it were me, I'd create a very simple and illustrative ESP32 application that connects to a remote data sink and attempts to push data at varying speeds and varying data sizes in an effort to reproduce the story in as simple a fashion as possible that would allow others to recreate on their systems with the minimal amount of effort and inconvenience.
Free book on ESP32 available here:

Posts: 1330
Joined: Sun May 08, 2016 4:11 am

Re: Socket outgoing buffer overflow

Postby ESP_Angus » Mon Feb 19, 2018 6:25 am

For UDP sockets, there is a behaviour where send() may return an error with errno set to ENOMEM if the outgoing driver layer transmit buffers are full. Sleeping for a single tick and then trying again is the best solution if you get a failure with this errno value. You can also increase the number of transmit buffers in TCP/IP menuconfig: ... buffer-num

We have discussed some other solutions with the WiFi team, but due to LWIP's architecture it's complex to find one which may not impact other aspects of TCP/IP stack performance.

Posts: 4
Joined: Fri Feb 16, 2018 6:05 pm

Re: Socket outgoing buffer overflow

Postby stubb0rn » Mon Feb 19, 2018 12:10 pm

OK I stripped my code to the essentials and dumped different sized packets to a `netcat` on a Linux host without any issues!
Going back to my original code it came to me, that there might be an issue in the protocol implmentation that causes the socket closing.

Return to “ESP32 IDF”

Who is online

Users browsing this forum: Baidu [Spider] and 13 guests