package kr.co.smu.network;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
public class EchoClient {
public static void main(String[] args) {
try{
Socket socket = new Socket("127.0.0.1", 10001);
BufferedReader keyboard =
new BufferedReader(new InputStreamReader(System.in));
BufferedReader in =
new BufferedReader(
new InputStreamReader(socket.getInputStream()));
PrintWriter out = new PrintWriter(socket.getOutputStream());
String line = null;
while((line = keyboard.readLine())!= null){
if(line.equals("quit"))
break;
out.println(line);
out.flush();
String echo = in.readLine();
System.out.println("서버가 보낸 문자열 : "+echo);
}
out.close();
in.close();
socket.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
'프로그래밍 > 자바' 카테고리의 다른 글
ChatClient (0) | 2016.01.22 |
---|---|
EchoThreadServer (0) | 2016.01.22 |
guestbook VO, DAO (0) | 2016.01.20 |
member (0) | 2016.01.19 |
BookDAOTest (0) | 2016.01.14 |