com.mischiefbox.dmud.net
Class Listener

java.lang.Object
  |
  +--com.mischiefbox.dmud.net.Listener
All Implemented Interfaces:
Runnable

public class Listener
extends Object
implements Runnable

Listens for new connections. Passes connections to the connection handler for lifecycle management.

Version:
$Id: Listener.java,v 1.1.1.1 2001/06/27 01:33:17 cjones Exp $
Author:
Chris Jones

Field Summary
protected  int BACKLOG
          The maximum number of un-accepted connections queued.
protected  boolean bListening
          Flag to indicate listening for new connections.
protected  ConnectionHandler handler
          The connection handler which gets new socket connections.
protected  int iPort
          The port on which to listen for new connections.
protected  ServerSocket server
          The server socket.
protected static int SLEEP_MILLIS
          The number of milliseconds to sleep between servicing each new socket request.
static String THREAD_NAME
          Listener thread name.
 
Constructor Summary
Listener(ConnectionHandler handler, int iPort)
          Create a new Listener.
 
Method Summary
 boolean isListening()
          Indicate if this is listening.
 void run()
          Listen for new connections and pass them to the connection handler.
 void start()
          Start listening.
 void stop()
          Stop listening.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREAD_NAME

public static final String THREAD_NAME
Listener thread name.

SLEEP_MILLIS

protected static final int SLEEP_MILLIS
The number of milliseconds to sleep between servicing each new socket request. Less busy servers can safely increase this number.

server

protected ServerSocket server
The server socket.

iPort

protected int iPort
The port on which to listen for new connections.

BACKLOG

protected int BACKLOG
The maximum number of un-accepted connections queued.

handler

protected ConnectionHandler handler
The connection handler which gets new socket connections.

bListening

protected boolean bListening
Flag to indicate listening for new connections.
Constructor Detail

Listener

public Listener(ConnectionHandler handler,
                int iPort)
Create a new Listener. Start listening and passing new connections to the connection handler.
Parameters:
handler - the connection handler.
iPort - the port on which to listen.
Method Detail

isListening

public boolean isListening()
Indicate if this is listening.

start

public void start()
Start listening.

stop

public void stop()
Stop listening.

run

public void run()
Listen for new connections and pass them to the connection handler.
Specified by:
run in interface Runnable


Copyright © 2001 by Christopher R. Jones. All Rights Reserved.