📄 debug16_4.java
字号:
package questions.c16;
import java.io.*;
import java.net.*;
public class Debug16_4 {
private InetAddress host;
private int port;
public Debug16_4( InetAddress host, int port ) {
this.host = host;
this.port = port;
}
public void run() {
try {
DatagramSocket client = new DatagramSocket();
String testData = "Test Data";
DatagramPacket outDgp
= new DatagramPacket( testData.getBytes(),
testData.length() );
client.send( outDgp );
byte[] buffer = new byte[256];
DatagramPacket inDgp = new DatagramPacket();
client.receive( inDgp );
client.close();
}
catch( IOException iox ) {
iox.printStackTrace();
}
}
public static void main( String[] args ) {
try {
InetAddress host = InetAddress.getLocalHost();
Debug16_4 client = new Debug16_4( host, 8189 );
client.run();
}
catch ( UnknownHostException uhx ) {
uhx.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -