FileDocCategorySizeDatePackage
Listen.javaAPI DocExample827Sat Jan 13 18:09:58 GMT 2001None

Listen

public class Listen extends Object
Listen -- make a ServerSocket and wait for connections.
author
Ian F. Darwin
version
$Id: Listen.java,v 1.2 2001/01/13 23:09:58 ian Exp $

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


	       
		ServerSocket sock;
		Socket  clientSock;
		try {
			sock = new ServerSocket(PORT);
			while ((clientSock = sock.accept()) != null) {

				// Process it.
				process(clientSock);
			}

		} catch (IOException e) {
			System.err.println(e);
		}
	
static voidprocess(java.net.Socket s)
This would do something with one client.

		System.out.println("Accept from client " + s.getInetAddress());
		// The conversation would be here.
		s.close();