Export (0) Print
Expand All

Socket.RemoteEndPoint Property

Gets the remote endpoint.

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

public EndPoint RemoteEndPoint { get; }

Property Value

Type: System.Net.EndPoint
The EndPoint with which the Socket is communicating.

ExceptionCondition
SocketException

An error occurred when attempting to access the socket. See the Remarks section for more information.

ObjectDisposedException

The Socket has been closed.

For a connection-oriented protocol, the RemoteEndPoint property gets the EndPoint that contains the remote IP address and port number to which the Socket is connected. You must cast this EndPoint to an IPEndPoint or DnsEndPoint, depending on the type of EndPoint used to connect, before retrieving any information. You can then access the Host property to retrieve the remote host, and the Port property to retrieve the remote port number. IPAddress information for the RemoteEndPoint is only available if a IPEndPoint was used to connect.

The RemoteEndPoint is set after a call to ConnectAsync. If you try to access this property earlier, RemoteEndPoint will throw a SocketException. If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

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

Community Additions

ADD
Show:
© 2014 Microsoft