package com.zy;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
public class UdpSever {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
DatagramSocket ds=new DatagramSocket(9999);
byte b[]=new byte[1024];
DatagramPacket dp=new DatagramPacket(b, b.length);
ds.receive(dp);
System.out.println(new String(b).trim());
String s="你好服务器";
DatagramPacket ndp=new DatagramPacket(s.getBytes(), s.getBytes().length,InetAddress.getLocalHost(),8888 );
ds.send(ndp);
}
}