InetAddress add = InetAddress.getLocalHost();
String ip = add.getHostAddress();
DatagramSocket ds = new DatagramSocket(50000);
while(true){
byte[] buf = "Hello world".getBytes();
DatagramPacket dp = new DatagramPacket(buf,buf.length,InetAddress.getByName(ip),40000);
ds.send(dp);
}
ds.close();
这么写问什么编译时会报:
UdpSend.java:18: 无法访问的语句ds.close();
|