à l'exception de PID, un coup d'oeil à ceci:
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners();
TcpConnectionInformation[] tcpConnections =
ipProperties.GetActiveTcpConnections();
foreach (TcpConnectionInformation info in tcpConnections)
{
Console.WriteLine("Local: {0}:{1}\nRemote: {2}:{3}\nState: {4}\n",
info.LocalEndPoint.Address, info.LocalEndPoint.Port,
info.RemoteEndPoint.Address, info.RemoteEndPoint.Port,
info.State.ToString());
}
Console.ReadLine();
Source: Netstat in C#
Un peu plus de recherche apportent ceci: Build your own netstat.exe with c#. Cela utilise P/Invoke pour appeler GetExtendedTcpTable
et en utilisant la même structure que netstat
.
Et pour obtenir aussi le PID? – Revious