TCPDisconnect Function

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
TCPDisconnect Function
C
void TCPDisconnect(
    TCP_SOCKET hTCP
);
Description

This function closes a connection to a remote node by sending a FIN (if currently connected). 

The function can be called a second time to force a socket closed by sending a RST packet. This is useful when the application knows that the remote node will not send an ACK (if it has crashed or lost its link), or when the application needs to reuse the socket immediately regardless of whether or not the remote node would like to transmit more data before closing. 

For client mode sockets, upon return, the hTCP handle is relinquished to the TCP/IP stack and must no longer be used by the application (except for an immediate subsequent call to TCPDisconnect() to force a RST transmission, if needed). 

For server mode sockets, upon return, the hTCP handle is NOT relinquished to the TCP/IP stack. After closing, the socket returns to the listening state allowing future connection requests to be serviced. This leaves the hTCP handle in a valid state and must be retained for future operations on the socket. If you want to close the server and relinquish the socket back to the TCP/IP stack, call the TCPClose() API instead of TCPDisconnect().

Preconditions

None

Parameters
Parameters 
Description 
hTCP 
Handle of the socket to disconnect. 
Returns

None

Remarks

If the socket is using SSL, a CLOSE_NOTIFY record will be transmitted first to allow the SSL session to be resumed at a later time.

Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.