fnGetTCP_state()

unsigned char fnGetTCP_state(USOCKET TCP_socket);

TCPSocket is the number of the TCP socket whose present state is to be returned.


The routine is used to request the state of a TCP socket. The return value is the present TCP socket state or an error TCP_STATE_BAD_SOCKET if the socket doesn't exist:
Note that the state values has been carefully designed to allow efficient checking of multiple state. For example:
if (!(ptr_TCP->ucTCP_state & (TCP_STATE_RESERVED | TCP_STATE_LISTEN | TCP_STATE_CLOSED))) {}
checks for states which would not allow a new connection to be achieved by checking several individual bits.

Example

    if (fnGetTCP_state(http_socket) & TCP_STATE_LISTEN) {
        fnDebugMsg("HTTP socket is in listening state\r\n");
    }


See the following forum thread for additional details about working with TCP sockets: µTasker forum TCP discussion.

Related functions

fnGetTCP_Socket();
fnReleaseTCP_Socket();
fnTCP_Listen();
fnTCP_Activity();
fnTCP_Connect();
fnTCP_close();




Please use the µTasker forum to ask specific questions.