Share via


RemoteEndPoint Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the remote endpoint.

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

Syntax

'Declaration
Public ReadOnly Property RemoteEndPoint As EndPoint
public EndPoint RemoteEndPoint { get; }
public:
property EndPoint^ RemoteEndPoint {
    EndPoint^ get ();
}
member RemoteEndPoint : EndPoint with get
function get RemoteEndPoint () : EndPoint

Property Value

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

Remarks

If you are using 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. If you are using a connectionless protocol, RemoteEndPoint contains the default remote IP address and port number with which the Socket will communicate. You must cast this EndPoint to an IPEndPoint before retrieving any information. You can then call the IPEndPoint..::..Address method to retrieve the remote IPAddress, and the IPEndPoint..::..Port method to retrieve the remote port number.

The RemoteEndPoint is set after a call to either Accept or Connect. 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.

.NET Framework Security

See Also

Reference

Socket Class

System.Net.Sockets Namespace