import java.io.*;
import java.net.*;
public class GameJava3_05_Socket{
public static void main(String[] args){
try{
Socket mySocket=new Socket("192.168.0.1",8080);
System.out.println("서버에 접속했습니다.");
BufferedReaderin=new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
PrintWriterout=new PrintWriter(new OutputStreamWriter(mySocket.getOutputStream()));
String msg="%%%접속을 허락해주세요.";
System.out.println("서버에게 보낸 메세지:"+msg);
out.println(msg);
out.flush();
System.out.println("서버로부터 받은 메세지:"+in.readLine());
mySocket.close();
}catch(MalformedURLException e){
System.out.println(e.toString());
}catch(IOException e){
System.out.println(e.toString());
}
}
}
'Programming > JAVA' 카테고리의 다른 글
[펌] [SWING]JFileChooser (0) | 2005.06.29 |
---|---|
[펌] 서버 소켓 예제 (0) | 2005.06.24 |
[펌] 13. 쓰레드(Thread) (0) | 2005.06.23 |
[펌] 통신을 위한 THREAD 프로그래밍 (0) | 2005.06.23 |
[펌] Swing (0) | 2005.06.17 |