±Û¾´ÀÌ :¿Í´Ï 1999³â 11¿ù 17ÀÏ 15:35:42
appletÀ» ÀÌ¿ëÇÑ Ã¤ÆÃÇÁ·Î±×·¥...
¿Ö ±×·±Áö...
óÀ½ Çѹø º¸³»°í ´Ù½Ã Area¿¡ ½áÁö±â Çϴµ¥
´Ù½Ã º¸³¾·Á°í ÇÏ¸é ²ÞÀûµµ ¾ÊµÇ³×¿ä....
°¡¸£ÃÄ ÁÖ½Ã¸é °í¸¿°Ú½À´Ï´Ù....
************ Ŭ¶óÀ̾ðÆ® ºÎºÐ **************
public void start(){
try{
userSocket = new Socket(Host , Port);
out = new PrintWriter(userSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
userSocket.getInputStream()));
}catch(UnknownHostException uhe){
contentTalk.append("Unknown host :" + uhe.getMessage());
}catch(IOException ioe){
contentTalk.append("IOException :" + ioe.getMessage());
}
contentTalk.append("Connected Successfully........");
scatter(); // textarea¿¡ ½áÁØ´Ù.
}
public void actionPerformed(ActionEvent cm){
out.println(Talk.getText() + newline);
// º¸³½´Ù.
}
public void scatter() {
try{
String talk;
// while((talk = in.readLine()) != null){
talk = in.readLine();
contentTalk.append(talk);
// }
}catch(IOException ioe){
contentTalk.setText("IOException :" + ioe.getMessage());
}
}
*************** ¼¹ö ****************************************
public void Connection( Socket eachSocket){
//
// Socket[HostMax] eachSocket = new Socket[HostMax];
// Thread[HostMax] eachThread = new Thread[HostMax];
// int i = 0;
PrintWriter out = null;
BufferedReader in = null;
try{
out = new PrintWriter(
eachSocket.getOutputStream(), true);
in = new BufferedReader(
new InputStreamReader(
eachSocket.getInputStream()));
String talk;
while( (talk = in.readLine()) != null){
out.println("you say "+ talk);
if(talk.equals("bye"))
break;
}
}catch( java.io.IOException ioe){
System.out.println("io error");
}
try{
out.close();
in.close();
eachSocket.close();
}catch(IOException ioe){
System.out.println("io close error");
}
}//Connnection