package play;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
public class FeiQDemo {
public static void main(String[] args) throws Exception {
while(true){
DatagramSocket datagramSocket=new DatagramSocket();
byte[] b=getData("").getBytes();
DatagramPacket datagramPacket=new DatagramPacket(b, b.length,InetAddress.getByName("192.168.107.74"),2425);
datagramSocket.send(datagramPacket);
datagramSocket.close();
}
}
public static String getData(String content){
StringBuilder sb=new StringBuilder();
sb.append("1.0:");
sb.append(System.currentTimeMillis()+":");
sb.append("呵呵:");
sb.append("192.168.107.74:");
sb.append("32:");
sb.append(content);
return sb.toString();
}
}
|