'how to only get Tcp connection status information for specific ip adress and port

I tried this

IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
TcpConnectionInformation[] tcpConnections = ipGlobalProperties.GetActiveTcpConnections();

string ipaddress = "134.65.6787,134.65.526.7,135.65.324.6";
int port = 1234;

foreach (TcpConnectionInformation tcpConnection in tcpConnections)
{
    Console.WriteLine("Local Address {0}:{1}\nForeign Address {2}:{3}\nState {4}",
                    tcpConnection.LocalEndPoint.Address,
                    tcpConnection.LocalEndPoint.Port,
                    tcpConnection.RemoteEndPoint.Address,
                    tcpConnection.RemoteEndPoint.Port,
                    tcpConnection.State);
}

How to make the result into a list?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source