-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEcoClient01.java
More file actions
45 lines (36 loc) · 1.12 KB
/
EcoClient01.java
File metadata and controls
45 lines (36 loc) · 1.12 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package network;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
// 키보드로 입력한 내용을 서버에 보내기
public class EcoClient01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Socket socket = null;
BufferedReader in = null;
PrintWriter out = null;
BufferedReader keyin = null;
try {
socket = new Socket("10.10.0.125", 12345);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream(), true);
keyin = new BufferedReader(new InputStreamReader(System.in));
String sendMsg = "";
String recvMsg = "";
while((sendMsg = keyin.readLine())!= null ) {
out.println(sendMsg);
recvMsg = in.readLine();
System.out.println("서버 >> " + recvMsg);
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}