Topic Path: Symbol Reference > Classes > TIdTCPConnection Class > TIdTCPConnection Methods > Disconnect Method > Disconnect Method (Boolean)
TIdTCPConnection.Disconnect Method (Boolean)

Disconnects the peer connection.

procedure Disconnect(
    ANotifyPeer: Boolean
); virtual; overload;
Indicates if the peer connection is notified when the connection is closed. 

Disconnect is an overloaded method used to disconnect from the peer for the connection. 

ANotifyPeer indicates if the peer connection is notified when the connection is closed. If the connection is still Connected, Disconnect triggers a hsDisconnecting status notification prior to closing the IOHandler for the connection. If the connection is not Connected, no action is performed. 

When FreeIOHandlerOnDisconnect contains True, the IOHandler for the connection will be freed and FreeIOHandlerOnDisconnect is reset to False. 

If the connection was Connected on entry to the method, Disconnect triggers the OnDisconnected event handler and sends a hsDisconnected status notification for the connection. 

Many descendant classes override the Disconnect method to provide termination commands and response handling required by a specific protocol. 

If you simply need to close a connection, you probably should call the Disconnect method, or the Close method in the IOHandler or Socket (when assigned).

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.