FileDocCategorySizeDatePackage
DaytimeObjectServer.javaAPI DocExample862Mon Mar 13 12:17:00 GMT 2000None

DaytimeObjectServer

public class DaytimeObjectServer extends Object
DaytimeObject - connect to the Daytime (ascii) service.
author
Ian F. Darwin
version
$Id: DaytimeObjectServer.java,v 1.2 2000/03/13 17:17:00 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);
		}