ProProxy Home

proproxy
Class ProAbstractTCPListener

java.lang.Object
  |
  +--proproxy.ProAbstractTCPListener
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ProHTTPListener, ProTCPListener

public abstract class ProAbstractTCPListener
extends java.lang.Object
implements java.lang.Runnable

ProAbstractTCPListener
The TCP connection pooler and dispatcher. Waits for a new connection, creates a new Processor for each new connection. Processors are cached in a stack. Each Processor puts itself back to the cache when it is done so that it can be used for the next request.
You are free to use this code and to make modifications provided this notice is retained.

If you found this useful, please add a note of acknowledgement to my guestbook. If you would like to report a bug or suggest some improvements, you are most welcome. I will be happy to help you use this piece of code.

Version:
1.20, 31st Oct, 2001
Author:
Tanmay K. Mohapatra

Constructor Summary
ProAbstractTCPListener(int iListenPort, java.lang.String sIncludeList, java.lang.String sExcludeList)
          Save the connection parameters
 
Method Summary
abstract  void createAndProcessRequest(java.net.Socket newSocket)
           
 boolean isListening()
           
abstract  void processRequest(java.lang.Object processor, java.net.Socket newSocket)
           
 void pruneCache()
          Check if there are too many processors in cache and remove extra ones
 void run()
          The listener loop.
 void startListening()
          If listener thread is stopped and not listening, start it.
 void stopListening()
          If listener thread is active and listening, stop it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProAbstractTCPListener

public ProAbstractTCPListener(int iListenPort,
                              java.lang.String sIncludeList,
                              java.lang.String sExcludeList)
Save the connection parameters
Method Detail

run

public void run()
The listener loop.
Specified by:
run in interface java.lang.Runnable

createAndProcessRequest

public abstract void createAndProcessRequest(java.net.Socket newSocket)

processRequest

public abstract void processRequest(java.lang.Object processor,
                                    java.net.Socket newSocket)

pruneCache

public void pruneCache()
Check if there are too many processors in cache and remove extra ones

startListening

public void startListening()
If listener thread is stopped and not listening, start it.

stopListening

public void stopListening()
If listener thread is active and listening, stop it.

isListening

public boolean isListening()
Returns:
true if the listener thread is active and listening

ProProxy Home