The tcp_close function initiates the procedure to close the TCP connection. It might take some time to close the connection. The argument socket specifies the handle of the socket whose connection is to be closed. TCPnet calls the listener callback function only, when a remote peer has closed the connection. If the socket closing is initiated locally by calling tcp_close, the callback function is not called. When a socket type is TCP_TYPE_SERVER or TCP_TYPE_CLIENT_SERVER, the socket does not close after calling tcp_close. The active connection is closed, and the socket transits to TCP_STATE_LISTEN. In this state, the socket is still able to accept incoming connections. To close the TCP_TYPE_SERVER socket, the function tcp_close needs to be called twice. The tcp_close function is in the RL-TCPnet library. The prototype is defined in rtl.h. note - After calling tcp_close the socket still remains allocated until you release it.
|