// 整理信息
byte[] buf = new byte[broadPacket.getLength()];
System.arraycopy(broadPacket.getData(), 0, buf, 0, buf.length);
byteArrayStram = new ByteArrayInputStream(buf);
objectStream = new ObjectInputStream(byteArrayStram);
Host host = (Host) objectStream.readObject();
host.setState(0);
if (!host.getIp().equals(SystemConf.hostIP)) {
if (!NetDomain.containHost(host)) {
host.setState(1);
NetDomain.addHost(host);
System.out.println(SystemConf.hostList.size());
// 回应广播, 发送本机信息去目标地址
if (host.getTag() == 0) {
InetAddress addr = InetAddress.getLocalHost();
String hostName = addr.getHostName();// 获取主机名
String ip = SystemConf.hostIP;// 获取ip地址
Map<String, String> map = System.getenv();
String userName = map.get("USERNAME");// 获取用户名
String userDomain = map.get("USERDOMAIN");// 获取计算机域
// 广播主机信息
Host res = new Host(userName, userDomain, ip,
hostName, 1, 1);
NetDomain.sendUdpData(broadSocket, res,
host.getIp(), SystemConf.broadcastPort);
}