±Û¾´ÀÌ :¶Ê¶ÊÀÌ 2000³â 6¿ù 17ÀÏ 15:24:35
Àú¹ø¿¡ Áú¹®Çߴµ¥..¹Ì¼÷ÇÑ ÇÁ·Î±×·¥¿Ã¸³´Ï´Ù.
Á¦¹ß Ç®Á×¾îÀÖ´Â ÀÌ ¾î¸°¾ç¿¡°Ô µµ¿òÀÇ ¼Õ±æÀ»!!!!
RMI·Î °£´ÜÇÑ ¼¹ö¿Í Ŭ¶óÀ̾ðÆ®ÀÇ Ã¤Æà ÇÁ·Î±×·¥Àä..
callback±¸Çöµµ ¾î¶»°Ô ÇؾßÇÏ´ÂÁö ¸ð¸£°Ú±¸¿ä..
½ÇÇàÀÌ Á¦´ë·Î Àß ¾ÈµÇ³×¿ä..
±ÞÇÕ´Ï´Ù¿ä!..
¾Æ½Ã¸é, ±Ó¼Ó¸» âµµ ¶ß¸é Á¤¸» °í¸¿°Ú½À´Ï´Ù..
¾Æ½Ã¸é Á¦¹ß Á» µµ¿ÍÁÖ¼¼¿ë!!
¹Ì¼÷ÇÑ ÇÁ·Î±×·¥ ¼Ò½ºÀÔ´Ï´Ù..
º¸½Ã°í °í¼ö´ÔÀÇ ¼öÁ¤ºÎŹÇÕ´Ï´Ù!!
¸ÕÀú answer
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Answer extends Remote{
void sendMessage(String str) throws RemoteException;
}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
±×´ã¿£ client
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.rmi.Naming;
import java.rmi.*;
public class Client extends JFrame implements ActionListener{
JButton b1;
JButton b2;
JTextField t1;
JTextField t2;
Answer send;
Client(String title){
super(title);
JPanel p = new JPanel();
JTextField t1 = new JTextField(10);
JTextField t2 = new JTextField(10);
JButton b1 = new JButton("IP");
JButton b2 = new JButton("send");
b1.addActionListener(this);
b2.addActionListener(this);
p.add(t1);
p.add(b1);
p.add(t2);
p.add(b2);
getContentPane().add(p);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == b1){
try{
Answer send = (Answer)Naming.lookup("//"+t1.getText() +"/Server");
}
catch(Exception a){
a.printStackTrace();
}
}
if(e.getSource() == b2){
try{
send.sendMessage(t2.getText());
}
catch(Exception a){
a.printStackTrace();
}
}
}
public static void main(String[] arg){
Client c = new Client("Client");
c.setSize(250,100);
c.setVisible(true);
}
}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
±×´ã¿£ server
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.rmi.Naming;
public class Server extends UnicastRemoteObject implements Answer{
public Server() throws RemoteException{
}
public void sendMessage(String str) throws RemoteException{
System.out.println(str);
}
public static void main(String[] arg){
try{
Server s = new Server();
Naming.rebind("Server",s);
}catch(Exception e){
e.printStackTrace();
}
}
}