FileDocCategorySizeDatePackage
DaytimeObjectServer.javaAPI DocExample879Sat Oct 26 09:53:50 BST 2002None

DaytimeObjectServer

public class DaytimeObjectServer extends Object
DaytimeObjectServer - server for the non-standard Time (object) service.
author
Ian F. Darwin
version
$Id: DaytimeObjectServer.java,v 1.3 2002/10/26 13:53:50 ian Exp $

Fields Summary
public static final short
TIME_PORT
The TCP port for the object time service.
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)


	     
		ServerSocket sock;
		Socket  clientSock;
		try {
			sock = new ServerSocket(TIME_PORT);
			while ((clientSock = sock.accept()) != null) {
				System.out.println("Accept from " + 
					clientSock.getInetAddress());
				ObjectOutputStream os = new ObjectOutputStream(
					clientSock.getOutputStream());

				// Construct and write the Object
				os.writeObject(new Date());

				os.close();
			}

		} catch (IOException e) {
			System.err.println(e);
		}