Topic Path: Symbol Reference > Classes > TIdIOHandler Class > TIdIOHandler Properties > ClosedGracefully Property
ContentsIndexHome
PreviousUpNext
TIdIOHandler.ClosedGracefully Property

Indicates that the connection has been closed by the peer for a connection.

property ClosedGracefully: Boolean;

ClosedGracefully is a read-only Boolean property that indicates if a connection has been closed by the peer for the connection. 

ClosedGracefully is updated in the CloseGracefully method to indicate when the condition has been encountered during the IO operation. Use CloseGracefully to set the property value and signal that the connection will end in the previously described manner. 

ClosedGracefully is be used to determine when the connection has been closed by the peer prior to performing an IO operation that would raise an Exception

ClosedGracefully is generally used in protocol-oriented communications when the server is allowed to close the connection without signalling its intent to the client, or when a connection has been lost and no data exists in the Indy buffering mechanism. 

Most conversational protocols (such as Mail, News, etc.) disconnect by sending a command to the server telling it that it will disconnect. The server replies with an acknowledgement of the disconnection request, and then both the client and server disconnect. In these cases an EIdConnClosedGracefully exception should not be raised, and if one occurs it is in fact an error and should be handled. 

In some cases no command will be issued, but both sides know when the other will disconnect based on the protocol. Often a client will connect, issue one command, receive the response from the server and disconnect. While no explicit command was issued by the client, the protocol states that the connection should be disconnected after one command and response. Some of the time protocols are examples of this. 

If one side of the connection just disconnects, the other side is left to detect this and then take appropriate action to terminate the session. With protocols that use this disconnection method you will see an EIdConnClosedGracefully exception, and it is normal behavior indicated by the ClosedGracefully.

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