| Visual Basic (Declaration) | |
|---|---|
<DescriptionAttribute("Returns the remote address/port the socket is connected to.")> <BrowsableAttribute(False)> Public ReadOnly Property RemoteEndPoint As IPEndPoint | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Tcp Dim value As IPEndPoint value = instance.RemoteEndPoint | |
| C# | |
|---|---|
[DescriptionAttribute("Returns the remote address/port the socket is connected to.")] [BrowsableAttribute(false)] public IPEndPoint RemoteEndPoint {get;} | |
| Managed Extensions for C++ | |
|---|---|
[DescriptionAttribute("Returns the remote address/port the socket is connected to.")] [BrowsableAttribute(false)] public: __property IPEndPoint* get_RemoteEndPoint(); | |
| C++/CLI | |
|---|---|
[DescriptionAttribute("Returns the remote address/port the socket is connected to.")] [BrowsableAttribute(false)] public: property IPEndPoint^ RemoteEndPoint { IPEndPoint^ get(); } | |
Property Value
The remote IPEndPoint that the Tcp object is using for communications.The following example demonstrates using the ConnectedChanged event to notify the user of the status of the connection.
| Visual Basic | Copy Code |
|---|---|
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# | Copy Code |
|---|---|
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"); } | |
null is returned when the Connected property is false. When the Tcp.Connected property is true this property returns the IPEndPoint instance representing the remote address and port.
To retrieve the remote IP address, access Tcp.RemoteEndPoint.Address. To retrieve the remote port, access Tcp.RemoteEndPoint.Port. As a shortcut, use the Tcp.RemoteEndPoint.ToString method to return the IP address and port in address:port notation.
Target Platforms: Microsoft .NET Framework 2.0
Copy Code