package cn
.itcast_02
;
import java
.io
.IOException
;
import java
.net
.DatagramPacket
;
import java
.net
.DatagramSocket
;
import java
.net
.InetAddress
;
public class ReceiveDome {
public static void main(String
[] args
) throws IOException
{
DatagramSocket ds
= new DatagramSocket(10086);
byte[] bys
= new byte[1024];
DatagramPacket dp
= new DatagramPacket(bys
,bys
.length
);
ds
.receive(dp
);
String ip
= dp
.getAddress().getHostAddress();
String s
= new String(dp
.getData(),0,dp
.getLength());
System
.out
.println(s
+"---"+ip
);
ds
.close();
}
}
转载请注明原文地址: https://lol.8miu.com/read-38322.html