simnet
Class TCPPingPongServer

java.lang.Object
  extended byjava.lang.Thread
      extended bysimnet.Application
          extended bysimnet.TCPPingPongServer
All Implemented Interfaces:
Pluggable, PlugoutListener, java.lang.Runnable, SimnetWindowListener

public class TCPPingPongServer
extends Application
implements Pluggable


Nested Class Summary
private  class TCPPingPongServer.TCPPingPongServerThread
          The thread that does all of the work for an open port.
 
Field Summary
(package private)  int connCount
           
(package private)  int port
           
(package private)  java.util.HashSet sessions
           
(package private)  ServerSocket ssock
           
 
Fields inherited from class simnet.Application
appid, appstart, frame, initialized, node, NODE_ID, pid, random, sim, win
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TCPPingPongServer()
           
 
Method Summary
 void close()
          Close the server.
 void close(int dummy)
          For compatibilty with EchoServer...
 void customInit()
          This is where an application can do any application-specific initializeation it requires.
 void open(int port)
          Opens the server.
 void open(java.lang.Integer port)
           
 boolean prePlugout(java.lang.Object replacement)
          To cleanup, just clear out the sessions table (the worker threads clean themselves up when sockets close).
 void run()
          Wait for connections, and spawn a thread to deal with them.
 void status()
          Print a status report
 
Methods inherited from class simnet.Application
closeWindow, finalize, getTitleString, initialize, plugoutNotification, printout, printout, processWindowCommand, rawOut, window
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

port

int port

connCount

int connCount

ssock

transient ServerSocket ssock

sessions

transient java.util.HashSet sessions
Constructor Detail

TCPPingPongServer

public TCPPingPongServer()
Method Detail

customInit

public void customInit()
Description copied from class: Application
This is where an application can do any application-specific initializeation it requires.

Overrides:
customInit in class Application

open

public void open(java.lang.Integer port)

open

public void open(int port)
Opens the server.


run

public void run()
Wait for connections, and spawn a thread to deal with them.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class Application

close

public void close()
Close the server.


close

public void close(int dummy)
For compatibilty with EchoServer...


status

public void status()
Print a status report


prePlugout

public boolean prePlugout(java.lang.Object replacement)
To cleanup, just clear out the sessions table (the worker threads clean themselves up when sockets close).

Specified by:
prePlugout in interface Pluggable
Returns:
if this object can now be removed (was the operation sucessful)