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.

CC3000 Socket Status

Hello,

One of my customers is trying to establish the reason for socket closure. Looking at the APIs, there does not seem to be a straightforward way to do this. Can you give me any pointers? They also don't want to create a socket with no timeout.

I don’t to create a socket with no timeout.  I simply want to be able to determine if a socket has been closed due to the socket inactivity timeout.  This would be useful for the Basic WiFi Demo where there is a UART interface.  If the user waits too long to send or receive data, the socket could timeout.  Currently, the only way to know is to attempt to send or receive data and wait for that to timeout.  If there was an event that was generated when the socket was closed, that could be used to inform the user the socket has been closed before they attempt to send or receive data.  This would be useful in our application because we could check the socket to make sure it is open before we attempt to send data, or attempt to receive data and wait for that timeout. 

Any pointers? Thanks.

  • Hi,

    You can listen for the HCI_EVNT_BSD_TCP_CLOSE_WAIT event. Once you receive it you can close the socket, otherwise the socket will time out. This event indicates that the client is done with this socket and it can be closed.

    You can also determine if a socket has timed out by calling getsockopt(...) as shown in HttpCore.c of the HTTP Server Application.