TsgcWebSocketClientMethods › Connected

Connected Method

Queries the underlying socket to determine whether the client is currently connected to the server.

Syntax

public bool Connected();

Return Value

True if the underlying TCP client reports an active connection; False otherwise. (Boolean)

Remarks

Connected delegates to the internal Indy TCP client's Connected method, which performs a low-level socket probe to detect the peer status. Because that probe can block the calling thread and increase CPU usage, Connected should be used sparingly. For most situations prefer the Active property, which is a cheap flag and safe to call from any thread. Connected may raise an exception if the TCP client has not been initialized yet.

Example


if (oClient.Connected())
  ShowMessage("The socket is still connected");

Back to Methods