日期:2014-05-20 浏览次数:20836 次
public class SendMessage implements Runnable {
private static SimpleDateFormat sdft = new SimpleDateFormat(
"MMM dd HH:mm:ss yyyy", Locale.ENGLISH);
public static void main(String[] args) {
System.out.println(sdft.format(new Date()));
for (int i = 0; i < 100; i++) {
new Thread(new SendMessage()).start();
}
}
@Override
public void run() {
try {
DatagramSocket socket = new DatagramSocket();
int i = 0;
while (i < 400000) {
String buff = "<189>"+sdft.format(new Date())+" ZJHZ_MS_WLAN_H3CBAS1-01_ST %%10DHCPSD/5/DHCPS_ALLOCATE_IP(l): -DEV_TYPE=SECPATH-PN=210231A0DGB116000046; DHCP server information: Server IP = 10.173.0.2, DHCP client IP = 10.173.12.186, DHCP client hardware address = 94db-c906-9133, DHCP client lease = 3600.";
DatagramPacket packet = new DatagramPacket(buff.getBytes(), buff.getBytes().length,
InetAddress.getByName("127.0.0.1"), 514);
socket.send(packet);
i++;
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} catch (SocketException e) {[code=java]