?? netclient.java
字號:
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public class NetClient {
private static int UDP_PORT_START = 2223;
private int udpPort;
public NetClient() {
udpPort = UDP_PORT_START ++;
}
public void connect(String IP, int port) {
Socket s = null;
try {
s = new Socket(IP, port);
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
dos.writeInt(udpPort);
System.out.println("Connected to server");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(s != null) {
try {
s.close();
s = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -