TCPWasReset Function

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
TCPWasReset Function
C
BOOL TCPWasReset(
    TCP_SOCKET hTCP
);
Description

This function is a self-clearing semaphore indicating whether or not a socket has been disconnected since the previous call. This function works for all possible disconnections: a call to TCPDisconnect, a FIN from the remote node, or an acknowledgement timeout caused by the loss of a network link. It also returns TRUE after the first call to TCPInit. Applications should use this function to reset their state machines. 

This function was added due to the possibility of an error when relying on TCPIsConnected returing FALSE to check for a condition requiring a state machine reset. If a socket is closed (due to a FIN ACK) and then immediately reopened (due to a the arrival of a new SYN) in the same cycle of the stack, calls to TCPIsConnected by the application will never return FALSE even though the socket has been disconnected. This can cause errors for protocols such as HTTP in which a client will immediately open a new connection upon closing of a prior one. Relying on this function instead allows applications to trap those conditions and properly reset their internal state for the new connection.

Preconditions

TCP is initialized.

Parameters
Parameters 
Description 
hTCP 
The socket to check. 
Return Values
Return Values 
Description 
TRUE 
The socket has been disconnected since the previous call. 
FALSE 
The socket has not been disconnected since the previous call. 
Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.