• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a simple program to detect all connection between two computer??Thanx.  RSS feed

 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx very much.
 
Rikard Qvarforth
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi maby this dosent answer your question but in the right way have a look on this:
Code Sample 2: DisplayNet.java
import java.io.*;
import java.net.*;
import java.util.*;
public class DisplayNet {
public static void main(String argv[]) throws Exception {
Enumeration e = NetworkInterface.getNetworkInterfaces();
while(e.hasMoreElements()) {
NetworkInterface netface = (NetworkInterface)
e.nextElement();
System.out.println("Net interface: "+netface.getName());
Enumeration e2 = netface.getInetAddresses();
while(e2.hasMoreElements()) {
InetAddress ip = (InetAddress) e2.nextElement();
System.out.println("IP address: "+ip.toString());
}
}
}
}
also take a look on this
http://java.sun.com/features/2002/08/j2se-network.html
 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But How if you use jdk1.3?? i use it now. Thanks anyway.
[ November 20, 2002: Message edited by: li jia ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!