Socket.Connected Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets a value that indicates whether a Socket is connected to a remote host as of the last operation.

Namespace:  System.Net.Sockets
Assembly:  System.Net (in System.Net.dll)

Syntax

'Declaration
Public ReadOnly Property Connected As Boolean
public bool Connected { get; }

Property Value

Type: System.Boolean
true if the Socket was connected to a remote resource as of the most recent operation; otherwise, false.

Remarks

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

The value of the Connected property reflects the state of the connection as of the most recent operation. The last ConnectAsync, ReceiveAsync, or SendAsync operation determines the current state. If you need to determine the current state of the connection, make a zero-byte SendAsync call. If the call completes successfully, then the socket is still connected; otherwise, the socket is no longer connected.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.