Scan for 500 IP10 seconds or so, an IP wait 0.3 seconds
Ashamed to say, I think it is written in Java process programming, a little bit for reference only:
Package Steeven
Import java.sql.*;
import java.io.*;
import java.util.*;
Import java.text.*;< br> import javax.servlet.http.*;
public class IP extends Common implements runnable{
public String IP;//IP, username, host name
ResultSet list;//Paging display Recordset
public Ip cur;//paging display current record
static public Hashtable ping = new Hashtable (); result set
static int threa after//ping DCount = 0; The number of current threads, preventing too many threads from destroying the computer
public IP () {}
Public IP (String Ip) {
This.ip=ip
Thread r = new Thread (this);
R.start ();
}
public static void Ping (String IP) throws exception{
//MAX 30 Threads
while (threadcount>30)
Thread.sle EP (50);
ThreadCount +=1;
IP p = new IP (IP);
}
public void Pingall () throws exception{
ThreadCount =0;
Ping = new Hashtable (),
while (Next ())//nex T () Place all LAN IP on cur
ping (cur.ip);
/wait for all Ping to close
while (threadcount>0)
Thread.Sleep;
}
public void Run () {
try{
Process p= runtime.getrunTime (). EXEC ("ping" +ip+ "-W 300-n 1");
InputStreamReader ir = new InputStreamReader (P.getinputstream ());
LineNumberReader input = new LineNumberReader (IR);
//Read result row
for (int i=1; i<7; i++)
Input.readline ()
String line= input.readline ();
if (line.length () <17 | | line.substring (8,17). Equals ("Timed out")
Ping.put (Ip,new Boolean (false));
else
Ping.put (ip,new Boolean (TRUE);
//thread End
ThreadCount-= 1;
} catch (IOException e) {}
}
public static void Main (string[] args) throws exception{
IP ip= new IP ();
Ip. Pingall ();
Java.util.Enumeration key = Ping.keys ();
String K;
while ((k = (String) key.nextelement ())!= null)
System.out.println (k + ":" +ping.get ());
}
}
1. Using ping is more stupid, but relatively simple
2. If ping succeeds, use nbtstat also can get host name, current username, MAC address ... Everything is in the grip:)