Export (0) Print
Expand All

TcpConnectionInformation.LocalEndPoint Property

Gets the local endpoint of a Transmission Control Protocol (TCP) connection.

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

public abstract IPEndPoint LocalEndPoint { get; }

Property Value

Type: System.Net.IPEndPoint
An IPEndPoint instance that contains the IP address and port on the local computer.

The following example displays endpoint information for active TCP connections.

        public static void GetTcpConnections()
        {
            IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
//            TcpConnectionInformation connections = properties.GetActiveTcpConnections();
            TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();

            foreach (TcpConnectionInformation t in connections)
            {
                Console.Write("Local endpoint: {0} ",t.LocalEndPoint.Address);
                Console.Write("Remote endpoint: {0} ",t.RemoteEndPoint.Address);
                Console.WriteLine("{0}",t.State);
            }
            Console.WriteLine();
        }

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft