📄 testnwclient.java
字号:
package trader.nw;
import java.io.*;
import java.net.*;
public class TestNwClient {
public static void main(String args[]) {
int port = 6001;
int count = 0;
Object obj = null;
NwClient nwc;
if (args.length > 0){
try {
port = Integer.parseInt(args[0]);
} catch(Exception e) {
System.out.println("TestNwClient " + e);
}
}
nwc = new NwClient("localhost", port);
try {
while (true) {
// send object
obj = "message" + count++;
try {
nwc.send(obj);
} catch(Exception e) {
System.out.println("TestNwClient " + e);
}
// receive object
obj = null;
try {
obj = nwc.receive();
System.out.println("TestNwClient received " + obj);
} catch(Exception e) {
System.out.println("TestNwClient receive " + e);
}
Thread.sleep(4000);
}
} catch(Exception e) {
System.out.println("TestNwClient: " + e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -