FileDocCategorySizeDatePackage
ListenInside.javaAPI DocExample1178Sun Feb 15 20:44:44 GMT 2004None

ListenInside

public class ListenInside extends Object
ListenInside -- make a server socket that listens only on a particular interface, in this case, one named by INSIDE_HOST.
author
Ian F. Darwin
version
$Id: ListenInside.java,v 1.2 2004/02/16 02:44:43 ian Exp $

Fields Summary
public static final short
PORT
The TCP port for the service.
public static final String
INSIDE_HOST
The name of the network interface.
public static final int
BACKLOG
The number of clients allowed to queue
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)


	       
		ServerSocket sock;
		Socket  clientSock;
		try {
			sock = new ServerSocket(PORT, BACKLOG, 
				InetAddress.getByName(INSIDE_HOST));
			while ((clientSock = sock.accept()) != null) {

				// Process it.
				process(clientSock);
			}

		} catch (IOException e) {
			System.err.println(e);
		}
	
static voidprocess(java.net.Socket s)
Hold server's conversation with one client.

		System.out.println("Connected from  " + INSIDE_HOST + 
			": " + s.getInetAddress(  ));
		// The conversation would be here.
		s.close();