📄 udpwatch.java
字号:
import java.net.*;
public class UdpWatch{
private DatagramSocket ds;
private DatagramPacket dp;
public static void main(String[] args)throws Exception{
UdpWatch d = new UdpWatch();
d.go();
}
public void go()throws Exception{
byte[] buff = new byte[64];
String s;
ds = new DatagramSocket(Udp.PORT);
dp = new DatagramPacket(buff,buff.length);
while(true){
ds.receive(dp);//hui zu se, wait();
s = new String(dp.getData());
System.out.println("From"+dp.getAddress()+": "+s);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -