System.Net.Sockets.Socket.Connected Property

Gets a value that indicates whether a System.Net.Sockets.Socket is connected to a remote host as of the last erload:System.Net.Sockets.Socket.Send or erload:System.Net.Sockets.Socket.Receive operation.

Syntax

public bool Connected { get; }

Value

true indicates that the current instance was connected at the time of the last I/O operation; false indicates that the current instance is not connected.

Remarks

The Connected property gets the connection state of the System.Net.Sockets.Socket as of the last I/O operation. When it returns false, the System.Net.Sockets.Socket was either never connected, or is no longer connected.

The value of the Socket.Connected property reflects the state of the connection as of the most recent operation. If you need to determine the current state of the connection, make a nonblocking, zero-byte Send call. If the call returns successfully or throws a WAEWOULDBLOCK error code (10035), then the socket is still connected; otherwise, the socket is no longer connected.

If you call erload:System.Net.Sockets.Socket.Connect on a User Datagram Protocol (UDP) socket, the Socket.Connected property always returns true; however, this action does not change the inherent connectionless nature of UDP.

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0