Chat freely about anything...

User avatar
By kolban
#33409 Consider an ESP8266 coded to use the Espressif SDK. Imagine a TCP connection is created between it and a back-end server. Now imagine that the back-end server has mega bytes of data that it wishes to send to the ESP8266 over time. Obviously, the amount of RAM in the ESP8266 is limited ... as such, it can't receive and buffer all the data until it is consumed. For this to appear to work, the ESP8266 would have to tell the source of the data when it may transmit the next chunk of data. Here is where I am getting puzzled.

In a Unix level sockets application, I can imagine a receiver of data not asking for more data until it executes a "read()" call to read some more. However, in an ESP8266, I believe we are supposed to register a receiver callback function that gets invoked whenever the partner sends new data and the receiver is expected to cache the data for later consumption. This doesn't appear to include any flow control function or capability. As such, my question becomes ... how would I achieve my goal of throttling the amount of data sent by the transmitter through my ESP8266 receiver?
User avatar
By lethe
#33412 With TCP, there should be no need for special handling. Congestion control is actually part of the TCP standard and should happen on the transport layer, regardless of whether the network API is using callbacks or blocking reads.
See https://en.wikipedia.org/wiki/Transmiss ... on_control
User avatar
By igrr
#33425 LwIP does have this mechanism, and an application can decide whether it is ready for more data or not.

In espconn this is exposed via espconn_recv_hold /unhold functions.