com.oreilly.servlet
Class DaemonHttpServlet

java.lang.Object
  extended by HttpServlet
      extended by com.oreilly.servlet.DaemonHttpServlet
Direct Known Subclasses:
RemoteDaemonHttpServlet

public abstract class DaemonHttpServlet
extends HttpServlet

A superclass for HTTP servlets that wish to accept raw socket connections. DaemonHttpServlet starts listening for client requests in its init() method and stops listening in its destroy() method. In between, for every connection it receives, it calls the abstract handleClient(Socket client) method. This method should be implemented by the servlet subclassing DaemonHttpServlet. The port on which the servlet is to listen is determined by the getSocketPort() method.

Version:
1.0, 98/09/18
Author:
Jason Hunter, Copyright © 1998
See Also:
RemoteDaemonHttpServlet

Constructor Summary
DaemonHttpServlet()
           
 
Method Summary
 void destroy()
          Halts the thread listening for socket connections.
abstract  void handleClient(java.net.Socket client)
          Handles a new socket connection.
 void init(ServletConfig config)
          Begins a thread listening for socket connections.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DaemonHttpServlet

public DaemonHttpServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Begins a thread listening for socket connections. Subclasses that override this method must be sure to first call super.init(config).

Parameters:
config - the servlet config
Throws:
ServletException - if a servlet exception occurs

handleClient

public abstract void handleClient(java.net.Socket client)
Handles a new socket connection. Subclasses must define this method.

Parameters:
client - the client socket

destroy

public void destroy()
Halts the thread listening for socket connections. Subclasses that override this method must be sure to first call super.destroy().