[Re] ÀúÀÇ ¼Ò½º¸¦ Âü°íÇϼ¼¿ä


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :À̼ºÈÆ 1999³â 11¿ù 18ÀÏ 16:32:32

In Reply to: ¾ÊµÇ³×¿ä... appletÀÇ °æ¿ì posted by ¿Í´Ï on 1999³â 11¿ù 16ÀÏ 20:10:36:

Á¦°¡ Çغ¸´Ï±î,
¾Æ·¡¿Í °°ÀÌ ÇÏ¸é µÉ°Í °°½À´Ï´Ù.
ºÎÁ·ÇÏÁö¸¸ µµ¿òÀÌ µÇ½Ã±æ ¹Ù¶ø´Ï´Ù.


/**
* ¼­¹ö ºÎºÐ
**/
import java.io.*;
import java.net.*;


public class EchoServer {
public static void main(String args[]) {
PrintWriter out;
BufferedReader in;
ServerSocket serverSocket;
Socket socket;
String msg;
int PORT = 5432;
try {
serverSocket = new ServerSocket( PORT, 1);
while (true) {
socket = serverSocket.accept();
out = new PrintWriter( socket.getOutputStream(), true);
in = new BufferedReader( new InputStreamReader(socket.getInputStream()));
while(true) {
msg = in.readLine();
System.out.println("Received Message : " + msg);
out.println("You said " + msg);
}
}
} catch (Exception e) { System.out.println(e); }
}
}




/**
* Ŭ¶óÀ̾ðÆ® ºÎºÐ
**/
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.applet.*;


public class EchoApplet extends Applet implements ActionListener {
int PORT = 5432;
BufferedReader in;
PrintWriter out;
Socket socket;
TextArea ta;
TextField tf;
String msg;

public void init() {
this.setLayout( new BorderLayout() );
ta = new TextArea(10, 40);
tf = new TextField(40);
tf.addActionListener(this);
this.add(ta, BorderLayout.CENTER);
this.add(tf, BorderLayout.SOUTH);
try {
socket = new Socket( getCodeBase().getHost(), PORT);
out = new PrintWriter( socket.getOutputStream(), true);
in = new BufferedReader( new InputStreamReader(socket.getInputStream()));
} catch(Exception e) {
System.out.println(e);
}
}

public void scatter() throws Exception {
msg = in.readLine();
ta.append(msg + "\n");
}

public void actionPerformed(ActionEvent ae) {
try {
out.println(tf.getText());
scatter();
tf.setText("");
} catch(Exception e) { System.out.println(e); }
}
}



´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]