Multiple client TCP connections not working?

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

cross mob
MiBo_4070331
Level 2
Level 2
First like received

I'm running a dev board as follows:

Starting WICED vWiced_006.002.001.0002

Platform NEB1DX_01 initialised

Started ThreadX v5.8

Initialising NetX_Duo v5.10_sp3

I'm having trouble with the following sequence - it doesn't seem to work correctly to me.

I have an array of 2 sockets as follows:

static wiced_tcp_socket_t  tcp_client_socket[2];

The code performs the following sequence:

1.. create a client socket (index 0) - works!

2.. bind socket (index 0) to wiced any port - works!

3. connect socket (index 0) to a server on some IP/port 7000 - works!

4. server closes the socket connection (index 0) created in steps 1-3

4a. I DO NOT disconnect the socket yet...

5. create a new client socket (index 1, different index from step 1) - works!

6. bind new socket (index 1) to wiced any port - works!

7. connect (index 1) to a server on some IP/port 7001 - FAIL with SOCKET_CLOSED error code.

Note: just so all the info is clear the server IP in steps 3 and 7 is the same - but note different port numbers.

I tried the above sequence where the 2nd socket connects prior to the first being closed by the server and that works.

Also if i disconnect the socket on 4a prior to connecting the 2nd port it works fine also.

So my question is: In the sequence why does the first socket (index 0) being closed by the server have any interaction with the 2nd socket (index 1)? Those two sockets should be completely independent of each other.

Thanks.

0 Likes
1 Solution
MiBo_4070331
Level 2
Level 2
First like received

Just to follow up - I was able to track down the issue. The server I was using to perform this test dumps a large amount of data to the socket after a connection is established. I believe this exhausted the tcp/ip buffer space on the WICED device and as a result the 2nd socket didn't work because it had no memory to use. Once I removed the data dump on the server side and replaced it with a much smaller data send the 2nd socket worked well.

View solution in original post

0 Likes
1 Reply
MiBo_4070331
Level 2
Level 2
First like received

Just to follow up - I was able to track down the issue. The server I was using to perform this test dumps a large amount of data to the socket after a connection is established. I believe this exhausted the tcp/ip buffer space on the WICED device and as a result the 2nd socket didn't work because it had no memory to use. Once I removed the data dump on the server side and replaced it with a much smaller data send the 2nd socket worked well.

0 Likes