Arm Mbed OS support forum

TCPSocket simultaneous connections


Is there a way to increase the number of simultaneous connections TCPSocket can handle? It currently only allows 3 connections which is not enough for my application. I found a setting “MBED_CONF_LWIP_SOCKET_MAX” which is in “mbed_config” and tried to change this from 4 to 6, however as soon as I press the compile button in Mbed Studio, it goes back to 4 by itself. I’m using OS5.



that needs a setting in mbed_app.json because the config.h is generated:

    "target_overrides": {
        "*": {
            "lwip.socket-max": 10,
            "lwip.tcp-socket-max": 10

Thanks Johannes.

What is the difference between lwip.socket-max and lwip.tcp-socket-max?

a socket can be used also for UDP, so it depends on your usage of sockets, TCP sockets require more RAM.
There are a lot of tuning parameters in
but for modifications you should check the lwip documentation. One thing I would change is
“lwip.tcp-mss”: 1460,
when you have enough ram, that is the max. number of data per frame and the default of 536 is low.

Where do I find the “mbed_lib.json” file so I can edit it?

Do not edit the mbed_lib.json, use the mbed_app.json in your project root directory.

The current Mbed examples should have a sample mbed_app.json or create this file and use the content as above.

I’ve added those lines to the mbed_app.json so it now looks like this:

“target_overrides”: {
“*”: {
“platform.stdio-convert-newlines”: true,
“lwip.socket-max”: 6,
“lwip.tcp-socket-max”: 6

however when I compile I get the error: Error: Could not parse mbed app configuration from /tmp/chroots/ch-40770bcb-67c4-4fc0-97bd-be53a2b529f7/src/mbed_app.json

a comma is missing after “ETHERNET”


That solved it. Many thanks.