Setting Multicast Time To Live in Java

http://www.peterfranza.com/2008/09/25/setting-multicast-time-to-live-in-java/

http://docs.oracle.com/javase/1.4.2/docs/guide/net/properties.html

http://www.cnblogs.com/lganggang131/archive/2012/02/13/2349740.html

http://javapub.iteye.com/category/107501?page=2

java.security.Security.setProperty("networkaddress.cache.ttl" , "60"); Amazon WebService.

http://www.0x13.de/index.php/tools.html

http://zhujinhuant-hotmail-com.iteye.com/blog/1040214

 

------------------------------------------------------------------------

http://code.google.com/p/bitcoinj/w/list
http://www.java-tips.org/java-se-tips/java.net/how-do-i-use-java-to-ping-a-host.html

http://www.davidreilly.com/java/java_network_programming/#3.5

http://www.blogjava.net/zhanglongsr/archive/2012/02/07/369543.html

 http://www.jguru.com/faq/view.jsp?EID=1274376

 

I have read this a few other places as well, but InetAddress.isReachable() instance method actually attempts a TCP 3-way handshake with the host's port 7 (Echo). If it cannot complete the handshake (SYN -> SYN,ACK -> ACK)) or does not get a reply (JavaDocs don't specify which) before the timeout specified, it returns false.

 

This is vastly different from an ICMP Ping, which sends ICMP Type 8 (echo) to the host and awaits an ICMP Type 0 (echo reply).

 

So, if the server is not listening on Port 7, isReachable(int) returns false, while if the network link is up, a Ping will receive a reply.

 

However, public boolean isReachable(NetworkInterface netif, int ttl, int timeout) will attempt an ICMP Echo (PING).

 

这个是正确的,我用wiresharks抓包验证了。

 

 public static boolean DoPing(String ipstr) {
  boolean retv = false;
  try {
   InputStream ins = Runtime.getRuntime()
     .exec("ping -n 1 -w 2000 " + ipstr).getInputStream();
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   int a = -1;
   while ((a = ins.read()) != -1) {
    out.write(a);
   }
   System.out.println(new String(out.toByteArray()));
   String parsstr = new StringTokenizer(new String(out.toByteArray()),
     "%").nextToken().trim();
   if (!parsstr.endsWith("100"))
    retv = true;
  } catch (Exception e) {
   e.printStackTrace();
   retv = false;
  }
  return retv;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ResHacker(软件版权修改器) 脚本说明: ************************************************************************************** 1 VERSIONINFO FILEVERSION 2,1,0,0 PRODUCTVERSION 2,1,0,0 FILEOS 0x4 FILETYPE 0x1 { BLOCK "StringFileInfo" { BLOCK "080404B0" { VALUE "FileVersion", "2, 1, 0, 0" //文件版本 VALUE "FileDescription", "HistoryClear" //描述 VALUE "LegalCopyright", "版权所有 (C) 2006" //版权 VALUE "Comments", "bbbbbbbb" //备注 VALUE "ProductVersion", "2, 1, 0, 0" //产品版本 VALUE "ProductName", "HistoryClear 软件" //产品名称 VALUE "PrivateBuild", "ssssssss" //个人用内部版本说明 VALUE "CompanyName", "ggggggg" //公司 VALUE "LegalTrademarks", "hhhhhhhh" //合法商标 VALUE "InternalName", "HistoryClear 应用程序" //内部名称 VALUE "SpecialBuild", "tttttttt" //特殊内部版本说明 VALUE "OriginalFilename", "HistoryClear.EXE" //源文件名 } } BLOCK "VarFileInfo" { VALUE "Translation", 0x0804 0x04B0 } } ************************************************************************************** VALUE "FileVersion", "1,0,0,0" //文件版本 VALUE "FileDescription", "快速关机,3秒钟内关机!" //描述 VALUE "LegalCopyright", "版权所有 (C) 2008" //版权 VALUE "ProductVersion", "1,0,0,0" //产品版本 VALUE "ProductName", "shutdown 软件" //产品名称 VALUE "CompanyName", "wwwckq.51.net software" //公司 VALUE "InternalName", "shutdown 应用程序" //内部名称 VALUE "OriginalFilename", "shutdown.exe" //源文件名
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值