Create the serversocket and use its stream to receive serialized objects
ServerSocket ser = null;
Socket soc = null;
String str = null;
Date d = null;
try {
ser = new ServerSocket(8020);
/*
* This will wait for a connection to be made to this socket.
*/
soc = ser.accept();
InputStream o = soc.getInputStream();
ObjectInput s = new ObjectInputStream(o);
str = (String) s.readObject();
d = (Date) s.readObject();
s.close();
// print out what we just received
System.out.println(str);
System.out.println(d);
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("Error during serialization");
System.exit(1);
}