Free
Class TCPServer

java.lang.Object
  |
  +--Free.TCPServer

public class TCPServer
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Runnable

The TCPServer Class opens a socket to listen for client connections which, when received, are spun out into new threads to keep the listening socket free to accept new clients. The class is based on original code from "Java Threads" from O'Reilly.

Version:
0.9 9 February 2001
Author:
Jason Kitcat

Constructor Summary
TCPServer()
           
 
Method Summary
 void run()
          run listens and accepts new connections, spinning them off into new threads if we're already listening to a data socket, process the data with overloaded run
 void run(java.net.Socket data)
          run this time the overloaded one deals with the data as we're on a data socket
protected  void startServer(int port)
          startServer creates and runs a new thread for a session
protected  void stopServer()
          stopServer does just that!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPServer

public TCPServer()
Method Detail

startServer

protected void startServer(int port)
                    throws java.io.IOException
startServer creates and runs a new thread for a session
Parameters:
port - A number indicating the port being used for the session

stopServer

protected void stopServer()
stopServer does just that!

run

public void run()
run listens and accepts new connections, spinning them off into new threads if we're already listening to a data socket, process the data with overloaded run
Specified by:
run in interface java.lang.Runnable

run

public void run(java.net.Socket data)
run this time the overloaded one deals with the data as we're on a data socket
Parameters:
data - Data being sent by the client