-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestClient.java
More file actions
31 lines (29 loc) · 964 Bytes
/
TestClient.java
File metadata and controls
31 lines (29 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.*;
import java.net.Socket;
public class TestClient {
public static void main(String[] args) {
try (
Socket cs = new Socket("127.0.0.1", 39468);
InputStream is = cs.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
OutputStream os = cs.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter bw = new BufferedWriter(osw);
) {
bw.write("Hi");
bw.flush();
// client
String str = br.readLine();
while (true) {
System.out.println("response: " + str);
str = br.readLine();
if (str == null) {
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}