public class SyslogDemo1 {
public static void main(String[] args) {
String content = "测试消息";
String ip = "127.0.0.1";
int port = 514;
DatagramSocket ds = null;
for(int i=0;i<10;i++){
try
{
ds = new DatagramSocket();
byte[] contents = content.getBytes("utf-8");
DatagramPacket packet = new DatagramPacket(contents,contents.length,
InetAddress.getByName(ip),port);
ds.send(packet);
}
catch(Exception ex){
}
finally
{
if(null != ds)
ds.close();
}
}
}
}