IP发送ICMP  用JAVA 能实现吗 ?
怎么实现啊?
大家帮帮忙啊

解决方案 »

  1.   

    import java.net.*;
    import java.io.*; 
    public class Test {
      
      public static byte[] transform(String str) {
        String[] x=str.split("\\.",4);
        byte[] ip = new byte[x.length];
        for(int i=0; i<x.length; i++) {
          System.out.println(x[i]);
          ip[i] = (byte) Integer.parseInt(x[i]);    }
        return ip;
      }
      public static void main(String[] args) {
      try {
        InetAddress add = InetAddress.getByAddress(transform("218.1.71.141"));
        System.out.println(add);
        System.out.println(add.isReachable(3000));
      }
      catch(UnknownHostException e) {
        System.out.println(e.toString());
      }
    catch(IOException e){
    System.out.println("IO");
    }
    }