LocalEndPoint Property

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

Gets the local endpoint.

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

public EndPoint LocalEndPoint { get; }

Property Value

Type: System.Net..::..EndPoint
The EndPoint that the Socket is using for communications.

The LocalEndPoint property gets an EndPoint that contains the local IP address and port number to which your Socket is bound. You must cast this EndPoint to an IPEndPoint before retrieving any information. You can then call the IPEndPoint..::..Address method to retrieve the local IPAddress, and the IPEndPoint..::..Port method to retrieve the local port number.

The LocalEndPoint property is usually set after you make a call to the Bind method. If you allow the system to assign your socket's local IP address and port number, the LocalEndPoint property will be set after the first I/O operation. For connection-oriented protocols, the first I/O operation would be a call to the Connect or Accept method. For connectionless protocols, the first I/O operation would be any of the send or receive calls.

Show: