dcsimg
how to get to know system properties of clients login into network.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   garima_shrivastava
Posted On:   Tuesday, April 13, 2004 03:48 AM

hi, byte [] b; String myAddr=null; try{ myAddr = InetAddress.getLocalHost().getHostAddress(); }catch(Exception e){ System.out.println("error is"+e); } int[] add =doBuildAddress(myAddr); for(int i=1;i <=254;i++){ try{ b=new byte[]{new Integer(add[0]).byteValue(), new Integer(add[1]).byteValue(), new Integer(add[2]).byteValue(), new Integer(i).byteValue()}; InetAddress address = InetAddress.getByAddress(b); String ip = address.getHostAddress(); System.out.println (ip); Socket s = new Socket(); NetworkInterface ni = NetworkInterface.getByInetAddress(address); Enumerati   More>>

hi,
byte [] b;
String myAddr=null;
try{
myAddr = InetAddress.getLocalHost().getHostAddress();

}catch(Exception e){
System.out.println("error is"+e);

}

int[] add =doBuildAddress(myAddr);
for(int i=1;i <=254;i++){
try{

b=new byte[]{new Integer(add[0]).byteValue(), new Integer(add[1]).byteValue(),
new Integer(add[2]).byteValue(),
new Integer(i).byteValue()};

InetAddress address = InetAddress.getByAddress(b);
String ip = address.getHostAddress();
System.out.println (ip);
Socket s = new Socket();
NetworkInterface ni = NetworkInterface.getByInetAddress(address);

Enumeration en = NetworkInterface.getNetworkInterfaces();
while(en.hasMoreElements()){
System.out.println("en"+en.nextElement).toString());

NetworkInterface nn =(NetworkInterface)en.nextElement();

System.out.println("display name is:"+nn.getDisplayName());

Enumeration e2 = nn.getInetAddresses();
while(e2.hasMoreElements()) {
InetAddress ip1 = (InetAddress) e2.nextElement();
System.out.println("IP address"+ip1.toString());

}
}
s.connect(new InetSocketAddress(ip,22),50);
System.out.println("connection successfull");


public int[] doBuildAddress(String myAddr){
int ip_split[]= new int[3];
int position=0;
for(int i=0;i <3;i++){
position = myAddr.indexOf(".");
if(position != -1){
ip_split[i] = Integer.parseInt(myAddr.substring(0,position).toString());
position++;
myAddr= myAddr.substring(position);
}

}

return ip_split;
}


this is my code.plz can anybody help me.

thanks

   <<Less
About | Sitemap | Contact