码迷,mamicode.com
首页 > 其他好文 > 详细

局域网活跃主机扫描

时间:2015-07-08 00:23:52      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package example;
 7 
 8 import java.io.IOException;
 9 import java.net.InetAddress;
10 
11 /**
12  *
13  * @author silianbo
14  */
15 public class test {
16 
17     public static void main(String[] args) throws IOException {
18         String ip = "192.168.1.";
19         for (int i = 1; i < 256; i++) {
20             String host = ip + i;
21             InetAddress ia = InetAddress.getByName(host);
22             boolean bool = ia.isReachable(1500);
23             if (bool) {
24                 System.out.println("主机: " + host + " 可用");
25             }
26 
27         }
28 
29     }
30 }

 

局域网活跃主机扫描

标签:

原文地址:http://www.cnblogs.com/silianbo/p/4628745.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!