TcpClient.Active 屬性


取得或設定值,指出是否已建立連線。Gets or sets a value that indicates whether a connection has been made.

 property bool Active { bool get(); void set(bool value); };
protected bool Active { get; set; }
member this.Active : bool with get, set
Protected Property Active As Boolean


如果已經建立連接,則為 true,否則為 falsetrue if the connection has been made; otherwise, false.


衍生自TcpClient的類別可以使用這個屬性來判斷連接嘗試是否成功。Classes deriving from TcpClient can use this property to determine if a connection attempt has succeeded. 它不會監視的持續線上狀態TcpClientIt does not monitor the ongoing connection state of TcpClient. 如果遠端主機關閉連接, Active將不會更新。If the remote host closes the connection, Active will not be updated. 如果您是衍生自TcpClient ,而且需要更密切注意連接狀態,請Connected使用Client屬性所傳回Socket之的屬性。If you are deriving from TcpClient and require closer attention to the connection state, use the Connected property of the Socket returned by the Client property.