July 28, 2014
Gets the local endpoint that contains the local IP address and port number to which the socket is bound. This is the endpoint that the socket is using for communications.
Assembly: System.Net (in System.Net.dll)
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 Address method to retrieve the local IPAddress, and the 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 ConnectAsync or AcceptAsync method. For connectionless protocols, the first I/O operation would be any of the send or receive calls.