try {
//向指定的ip和端口发送数据~!
//先说明一下数据是谁发送过来的!
byte[] ip = InetAddress.getLocalHost().getHostAddress().getBytes();
dp = new DatagramPacket(ip, ip.length, sendIAD, QQReceive.getPort());
ds.send(dp);
//这里主要是因为多可数据报包发送时会产生丢包的情况...所以暂停一段时间!
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
}
dp = new DatagramPacket("PARAGRAPH".getBytes(), "PARAGRAPH".getBytes().length, sendIAD, QQReceive.getPort());
ds.send(dp);
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
}
dp = new DatagramPacket(bt, bt.length, sendIAD, QQReceive.getPort());
ds.send(dp);
} catch (IOException e1) {
e1.printStackTrace();
}
本文转自 小眼儿 博客园博客,原文链接:http://www.cnblogs.com/hujunzheng/p/4005459.html,如需转载请自行联系原作者