TsgcTCPClient › Methods › Disconnect
Closes the TCP connection synchronously and blocks the caller until the socket is closed or the timeout elapses.
function Disconnect(const aTimeout: Integer = 10000): Boolean;
| Name | Type | Description |
|---|---|---|
aTimeout | const Integer | Maximum time in milliseconds to wait for the connection to be closed. Defaults to 10000 (10 seconds). |
True when the client has been fully disconnected within the timeout; False if the timeout expired first. (Boolean)
Disconnect is the blocking counterpart to setting Active := False. It clears Active and then waits on an internal event until the socket is torn down or the timeout fires. If the client is already disconnected, the method returns True immediately. Because the TCP client does not exchange a protocol-level close frame, the socket is simply shut down at the transport level. Use Stop instead when you need a non-blocking disconnect from a secondary thread.
if oClient.Disconnect(10000) then
ShowMessage('Disconnected')
else
ShowMessage('Not Disconnected');