// The Pinger object measures network latency by sending a packet
// to the UDP Echo Port (Port 7) and timing how long it takes.
// We use this port instead of ICMP because I would have to
// use native methods in order to produce ICMP packets.

解决方案 »

  1.   

    难道java中不能实现ping的功能吗?高手在哪?
      

  2.   

    你可以访问http://go3.163.com/~swing/index1.html,那里提供了一个“网络探险者”来实现Ping功能,Ping就是Icmp协议,详细的协议信息,可以在http://www.cis.ohio-state.edu/hypertext/information/rfc.html找到。****** http://gyf1024.yeah.net ******
      

  3.   

    ..
    Some possible BSD options that are not supported in java: 
    RAW/ICMP SOCKETS:
    The main argument in favor of this one seemed to be so people could write "ping" in java. Security nightmare. Must be root on UNIX machines. 
    ...(http://java.sun.com/j2se/1.3/docs/guide/net/socketOpt.html)
    --------------------------------------------------------------------------------
    Q10.21
    Will raw sockets ever be introduced -- and if not, how can I create ICMP messages so that I can do operations like `ping'? (this is the only one which has no answer in FAQ)(http://java.sun.com/docs/books/faq/faqionet.html#s10.4)This is words from java.sun.comSo, I think maybe u can't write 'ping' in Java.
      

  4.   

    gyf1024:多谢您提供的资料,但我需要ping的源码,如能提供源码,不胜感激!
    全体参与者:多谢您们的参与,请继续提供帮助!
      

  5.   

       如果你是想学习的话,那么你可以和“网络探险者”的作者联系一下,看看他能否向你提供代码(或者你可以尝试用JAD反编译一下^_^),对于JAVA实现PING来说难点应该是理解Icmp协议,真正JAVA代码实现起来应该比较容易了。
      

  6.   

    多谢gyf1024的热情帮助,本人在此表示最诚挚的谢意!
      

  7.   

    would you please post the code?
    or email to me? 
    [email protected]
    I will really appreciate it.