¼Ò½º¿Ã¸³´Ï´ç...


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

±Û¾´ÀÌ :[¿µµ¹ÀÌ] 1998³â 10¿ù 10ÀÏ 09:18:01

In Reply to: [Q] ¼ÒÄÏ¿¬°á¿¡¼­ ObjectInputStream°ú ObjectOutputStream ¾²´Â¹ý. posted by ¹ÚÁ¾¿± on 1998³â 10¿ù 10ÀÏ 03:58:05:

- ¼­¹ö -
import java.io.*;
import java.net.*;
import java.util.Date;
import java.util.Vector;


public class DateServer extends Thread
{
protected ObjectOutputStream out;
protected Vector registry;

public DateServer(Socket s) throws IOException
{
registry = new Vector();

OutputStream o = s.getOutputStream();
BufferedOutputStream bO = new BufferedOutputStream(o);
out = new ObjectOutputStream(bO);
}

public void run()
{
try
{
registry.addElement(new Date());

out.writeObject(registry);
out.close();
}catch(IOException e){}
}

public static void main(String args[]) throws IOException
{
ServerSocket server = new ServerSocket(1905);

while(true)
{
System.out.println("waiting...");
Socket client = server.accept();
System.out.println("Accepted from "+client.getInetAddress());
DateServer c = new DateServer(client);
c.start();
}
}
}


- Ŭ¶óÀ̾ðÆ® -
import java.io.*;
import java.net.*;
import java.util.Date;
import java.util.Vector;


public class DateClient
{
public static void main(String args[]) throws IOException, ClassNotFoundException
{
Socket s = new Socket("127.0.0.1",1905);
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
Vector when = (Vector)in.readObject();
in.close();
System.out.println((Date)when.elementAt(0));
}
}


¼Ò½º ¼³¸íÀº ³Ê¹«µµ °£´ÜÇؼ­....
±×³É ³¯Â¥,½Ã°£ Âï´Â°ÍÀÓ´ç...



´ÙÀ½ ±Ûµé:



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

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


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