This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3120MOD: SL_ERROR_BSD_ECLOSE - Is the socket actually closed?

Part Number: CC3120MOD


Hi,

During some testing we've found that sl_Send(...) returns -1.  We suspect this is just a normal issue, specifically with Dropbox.

As a result of the failed send, we close the socket by issuing sl_Close(socketID)

We notice that sl_Close(..) returns SL_ERROR_BSD_ECLOSE, indicating "that the close socket failed to transmit all queued packets".

When I create a new socket, I notice the socket ID increments by one.

My questions are:

1. When I call sl_Close() and I get a response of SL_ERROR_BSD_ECLOSE, is the socket actually closed?

2. Is it the normal operation of the CC3120MOD to increment to the next socket ID when calling sl_Socket(..), or should it re-use the last closed socket? 

3. If CC3120MOD does not re-use the last socket ID after a close, what happens when the socket ID reaches greater than 32K?

4. Can I do anything better to prevent the SL_ERROR_BSD_ECLOSE error?. Do I need to flush the socket somehow?

Thanks.

  • Hi,

    1. Yes, the socket is closed. 

    2. It is dependent on the use-case. You cannot assume anything about the new socket id (sometime an id is not reused immediately as it takes some extra internal processing after the close return until the socket entry is completely freed).

    3. you will get the socket descriptor in the valid range. there is nothing that prevent us from reusing the same id.

    4. you can try to increase the close timeout (using the SL_SO_LINGER socket option).

    Br,

    Kobi

  • Thanks again Kobi,

    We do see the socket index incrementing over night, but no cause for concern.

    The underlying issue of why the connection gets closed by the server in the first place is under-investigation, I'll probably post a new thread when we solve it.

    Thanks!