Post topics, source code that relate to the Arduino Platform

User avatar
By dannybackx
#47565 Hey,

Is the number of TCP or UDP sockets limited ? I seem to remember reading about that but maybe that was a bad dream :-) I can't seem to find such info now.

Thanks,

Danny
User avatar
By dannybackx
#47613 Thanks for pointing me in the right direction. The ESP8266 SDK Programming Guide explains some of the calls, and some experimenting shows it's set to 5 by default, and can be pushed to 15.

Code: Select all  uint8 mc = espconn_tcp_get_max_con();
  Serial.printf("espconn_tcp_get_max_con -> %d\n", mc);

  sint8 rc = 0;
  for (uint8 i = 8; i<26 && rc >= 0; i++) {
    rc = espconn_tcp_set_max_con(i);
    uint mc = espconn_tcp_get_max_con();
    Serial.printf("Set max to %d", i);
    Serial.printf(" -> %d, max %d\n", rc, mc);
  }


espconn_tcp_get_max_con -> 5
Set max to 8 -> 0, max 8
Set max to 9 -> 0, max 9
Set max to 10 -> 0, max 10
Set max to 11 -> 0, max 11
Set max to 12 -> 0, max 12
Set max to 13 -> 0, max 13
Set max to 14 -> 0, max 14
Set max to 15 -> 0, max 15
Set max to 16 -> -12, max 15
User avatar
By Inq720
#71690 A very old thread, but it seems appropriate to add this here...

I've been playing around with using espconn_tcp_set_max_con() and the above testing code does work as shown; however, when I keep incoming connections open on a web server app, the 5th connection halts the flow (when espconn_tcp_set_max_con is set to 15). As expected, about two minutes later it did pop into ClientContext::_s_error with a ERR_CONN value. Even after this, it would not permit a new connection.