Retrieving All Active TCP Connections
Use the IPGlobalProperties.GetActiveTcpConnections method
using System.Net.NetworkInformation; public static void ShowActiveTcpConnections() { Console.WriteLine("Active TCP Connections"); IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation[] connections = properties.GetActiveTcpConnections(); foreach (TcpConnectionInformation c in connections) { Console.WriteLine("{0} <==> {1}", c.LocalEndPoint.ToString(), c.RemoteEndPoint.ToString()); } }
A source:
https://msdn.microsoft.com/en-us/library/system.net.networkinformation.ipglobalproperties.getactivetcpconnections.aspx
Note: This gives you only active TCP connections .
A shorter version of the code above.
foreach (var c in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections()) { ... }
Retrieving all networked computers
Better to do a ping scroll. It takes a few seconds to complete 254 IP addresses. The solution is here fooobar.com/questions/300595 / ...
source share