Share via


Socket.RemoteEndPoint Property

Gets the remote endpoint with which the current socket is communicating.

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

Syntax

public EndPoint RemoteEndPoint { get; }

Property Value

An EndPoint object specifying the endpoint with which the current socket is communicating.

Remarks

If you are using a connection-oriented protocol, the RemoteEndPoint property gets an EndPoint object that contains the remote IP address and port number to which the current socket is connected. If you are using a connectionless protocol, the returned EndPoint object contains the default remote IP address and port number with which the socket will communicate. You must cast this EndPoint object to an IPEndPoint object before retrieving any information. You can then call the IPEndPoint.Address method to retrieve the remote IP address, and call the IPEndPoint.Port method to retrieve the remote port number.

The RemoteEndPoint property is set after a call to either the Connect method or the Accept method. If you try to access the RemoteEndPoint property earlier, it will throw a SocketException exception. If you receive this type of exception, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows® Sockets 2.0 API error code documentation in the MSDN® Library for a detailed description of the error.

Version Information

Available in .NET Micro Framework version 2.0, 2.5

See Also

Reference

Socket Class
Socket Members
System.Net.Sockets Namespace