|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
simnet.Application
submission.Demo.EchoServer
submission.Demo.TCPEchoServer
An example of an EchoServer implemented with UDP. Unlike the UDP example, this echo server only runs on one port at a time.
| Nested Class Summary | |
private class |
TCPEchoServer.TCPEchoServerThread
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 submission.Demo.EchoServer |
prefix |
| Fields inherited from class simnet.Application |
appid, appstart, node, NODE_ID, pid, random, sim |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
TCPEchoServer()
|
|
| 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. |
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 submission.Demo.EchoServer |
close, open, setPrefix |
| 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 |
int port
int connCount
transient ServerSocket ssock
transient java.util.HashSet sessions
| Constructor Detail |
public TCPEchoServer()
| Method Detail |
public void customInit()
Application
customInit in class Applicationpublic void open(int port)
open in class EchoServerpublic void run()
run in interface java.lang.Runnablerun in class Applicationpublic void close()
public void close(int dummy)
close in class EchoServerpublic void status()
status in class EchoServerpublic boolean prePlugout(java.lang.Object replacement)
prePlugout in interface Pluggable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||