What's the limitation of number of sockets can be created at the same time?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Test on sdk3.0.1, with FreeRTOS+LwIP.

Below code snip shows wiced_tcp_create_socket fails if i >= 5.

The fail result is 25 (SOCKET_CREATE_FAIL).

Which means I can only successfully create 5 sockets at the same time. (0 ~ 4).

for (i = 0; i < 10; i ++) {

            result = wiced_tcp_create_socket(&socket, WICED_STA_INTERFACE);

            if (result != WICED_SUCCESS) {

                WPRINT_APP_INFO(("wiced_tcp_create_socket fails %u  i=%d\r\n", result , i));

            }

}

So any limitation about the number of sockets can be created at the same time?

0 Likes
1 Solution

Hi Sam Lin,

Also change the following to the number of sockets required

MEMP_NUM_TCP_PCB and  MEMP_NUM_UDP_PCB in opt.h

/**

* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One

* per active UDP "connection".

* (requires the LWIP_UDP option)

*/

#ifndef MEMP_NUM_UDP_PCB

#define MEMP_NUM_UDP_PCB                10

#endif

/**

* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.

* (requires the LWIP_TCP option)

*/

#ifndef MEMP_NUM_TCP_PCB

#define MEMP_NUM_TCP_PCB                10

#endif

Let me know if you face any issues.

thnx

vik86

View solution in original post

0 Likes
7 Replies
GregG_16
Employee
Employee
50 sign-ins 25 sign-ins 25 comments on KBA

Hello,

LWIP uses pre-allocated pool.

The fixed sized is controlled by a variable.  We may need to change the configuration to allow more than 5.

In lwipopts.h check, MEMP_NUM_NETCONN is defined to be 8, if you increase this, does this allow you to have more?

0 Likes
Anonymous
Not applicable

Hi gangi,

Below code always fails at "i = 5 , result=25".

int i;

for (i = 0; i < 10; i ++) {

        wiced_result_t result = wiced_tcp_create_socket(&test_socket, WICED_STA_INTERFACE);

        if (result != WICED_SUCCESS) {

                WPRINT_APP_INFO(("i = %d , result=%u\r\n", i , result));

                break;

        }

}

I have changed MEMP_NUM_NETCONN to 16, but the test result is still the same.

0 Likes

Can you confirm this is still an issue in SDK 3.1.0?

Anonymous
Not applicable

Hi Gangi,

I just test again with sdk 3.1.0 and still hit this issue with exactly the same result.

Thanks.

0 Likes

Thank you for confirming.

0 Likes

Hi Sam Lin,

Also change the following to the number of sockets required

MEMP_NUM_TCP_PCB and  MEMP_NUM_UDP_PCB in opt.h

/**

* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One

* per active UDP "connection".

* (requires the LWIP_UDP option)

*/

#ifndef MEMP_NUM_UDP_PCB

#define MEMP_NUM_UDP_PCB                10

#endif

/**

* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.

* (requires the LWIP_TCP option)

*/

#ifndef MEMP_NUM_TCP_PCB

#define MEMP_NUM_TCP_PCB                10

#endif

Let me know if you face any issues.

thnx

vik86

0 Likes
Anonymous
Not applicable

Hi vik86,

yes, that is the setting we are looking for.

BTW, do you have document about adjusting these settings in WICED-SDK?

Some settings a not very trivial, for example,

I'd like to know how to set MEM_SIZE setting in

WICED/network/LwIP/ver1.4.0.rc1/src/include/lwip/opt.h

And also how to set proper value for LWIP_NUM_PACKET_BUFFERS_IN_POOL.

(My question is how to calculate the *proper value* we need?)

thanks.

0 Likes