//program for server
import java.io.*;
import java.net.*;
import java.util.*;
class tcpobjwrite
{
public static void main(String args[]) throws Exception
{
import java.net.*;
import java.util.*;
class tcpobjwrite
{
public static void main(String args[]) throws Exception
{
ServerSocket ss;
Socket s;
ss = new ServerSocket(8888);
s = ss.accept();
ObjectOutputStream oos;
oos = new ObjectOutputStream(s.getOutputStream());
oos.writeObject(new Date());
Socket s;
ss = new ServerSocket(8888);
s = ss.accept();
ObjectOutputStream oos;
oos = new ObjectOutputStream(s.getOutputStream());
oos.writeObject(new Date());
oos.close();
s.close();
ss.close();
}
}
s.close();
ss.close();
}
}
------------------------------------------------------------------------
/* Program for client */
import java.io.*;
import java.net.*;
import java.util.*;
class tcpobjread
{
public static void main(String args[]) throws Exception
{
import java.io.*;
import java.net.*;
import java.util.*;
class tcpobjread
{
public static void main(String args[]) throws Exception
{
Socket s;
s = new Socket("localhost",8888);
s = new Socket("localhost",8888);
ObjectInputStream ois;
ois = new ObjectInputStream(s.getInputStream());
Date d = (Date)ois.readObject();
ois = new ObjectInputStream(s.getInputStream());
Date d = (Date)ois.readObject();
System.out.println("Hello"+d);
ois.close();
}
}
No comments:
Post a Comment