客户端:
String cIP = "...";
DatagramPacket packet = new DatagramPacket(buf,buf.length,InetAddress.getByName(cIP),10000);
服务器端:
byte[] buf = new byte[1024];
DatagramPacket packet = new DatagramPacket(buf,buf.length);
recive.receive(packet);
String sIP = packet.getAddress().getHostAddress();
这里面获取到 sIP 的值是客户端的ip地址,还是客户端创建数据包是封起来的那个cIP的值呀?
|