Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know where I got this code from anymore. The last piece of code is from me (getIPAddress())</p> <p>It reads your ip to get the base ip of the network.</p> <p>Credits go to the author:</p> <pre><code>static void Main(string[] args) { string ipBase = getIPAddress(); string [] ipParts = ipBase.Split('.'); ipBase = ipParts[0] + "." + ipParts[1] + "." + ipParts[2] + "."; for (int i = 1; i &lt; 255; i++) { string ip = ipBase + i.ToString(); Ping p = new Ping(); p.PingCompleted += new PingCompletedEventHandler(p_PingCompleted); p.SendAsync(ip, 100, ip); } Console.ReadLine(); } static void p_PingCompleted(object sender, PingCompletedEventArgs e) { string ip = (string)e.UserState; if (e.Reply != null &amp;&amp; e.Reply.Status == IPStatus.Success) { if (resolveNames) { string name; try { IPHostEntry hostEntry = Dns.GetHostEntry(ip); name = hostEntry.HostName; } catch (SocketException ex) { name = "?"; } Console.WriteLine("{0} ({1}) is up: ({2} ms)", ip, name, e.Reply.RoundtripTime); } else { Console.WriteLine("{0} is up: ({1} ms)", ip, e.Reply.RoundtripTime); } lock (lockObj) { upCount++; } } else if (e.Reply == null) { Console.WriteLine("Pinging {0} failed. (Null Reply object?)", ip); } } public static string getIPAddress() { IPHostEntry host; string localIP = ""; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { localIP = ip.ToString(); } } return localIP; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload