Connected Property

Socket.Connected Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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)

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.

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.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

© 2017 Microsoft