Dart.PowerTCP.SslSockets Namespace > Tcp Class : LocalEndPoint Property (Tcp) |
Returns the local address the socket is bound to.
[Visual Basic]
<DescriptionAttribute("Local IP EndPoint when the socket is connected")>
<BrowsableAttribute(False)>
Public ReadOnly Property LocalEndPoint As IPEndPoint
[C#]
[DescriptionAttribute("Local IP EndPoint when the socket is connected")]
[BrowsableAttribute(false)]
public IPEndPoint LocalEndPoint {get;}
[C++]
[DescriptionAttribute("Local IP EndPoint when the socket is connected")]
[BrowsableAttribute(false)]
public: __property IPEndPoint* get_LocalEndPoint();
[C++/CLI]
[DescriptionAttribute("Local IP EndPoint when the socket is connected")]
[BrowsableAttribute(false)]
public:
property IPEndPoint^ LocalEndPoint {
IPEndPoint^ get();
}
The local IPEndPoint that the Tcp object is using for communications.
null is returned when the Connected property is false. When the Connected property is true this property returns the IPEndPoint instance representing the local address and port. If a local interface was specified using the Connect or BeginConnect to connect to the host, this property should reflect that interface. Otherwise this property will reflect the default interface.
To retrieve the local IP address, access Tcp.LocalEndPoint.Address. To retrieve the local port, access Tcp.LocalEndPoint.Port. As a shortcut, use the Tcp.LocalEndPoint.ToString method to return the IP address and port in address:port notation.
The following example demonstrates using the ConnectedChanged event to notify the user of the status of the connection.
[Visual Basic]
Private Sub Tcp1_ConnectedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tcp1.ConnectedChanged
' Get current state of connection
If Tcp1.Connected Then
Debug.WriteLine("Connection made")
' Display info about the local/remote endpoints
Debug.WriteLine("Local endpoint: " + Tcp1.LocalEndPoint.ToString())
Debug.WriteLine("Remote endpoint: " + Tcp1.RemoteEndPoint.ToString())
Else
Debug.WriteLine("Connection closed")
End If
End Sub
[C#]
private void tcp1_ConnectedChanged(object sender, System.EventArgs e)
{
// Get current state of connection
if(tcp1.Connected)
{
Debug.WriteLine("Connection made");
// Display info about the local/remote endpoints
Debug.WriteLine("Local endpoint: " + tcp1.LocalEndPoint.ToString());
Debug.WriteLine("Remote endpoint: " +
tcp1.RemoteEndPoint.ToString());
}
else
Debug.WriteLine("Connection closed");
}
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Send comments on this topic.
Documentation version 1.1.2.0.
© 2008 Dart Communications. All rights reserved.