|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
org.neo.swarm.util.network.tcp.NIOTcpServer
NBlocking ServerSocketFactory - pumps out incoming events onto the associated channels SocketStream that gets processed by the next available thread in the pool.
| Field Summary |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
NIOTcpServer(ListenCallback callback,
ThreadPool pool,
int bufferSize,
java.net.InetAddress bind,
int port,
long timeout)
|
|
| Method Summary | |
boolean |
isStarted()
|
void |
listen()
|
protected void |
readDataFromSocket(java.nio.channels.SelectionKey key)
Sample data handler method for a channel with data ready to read. |
protected void |
registerChannel(java.nio.channels.Selector selector,
java.nio.channels.SelectableChannel channel,
int ops,
java.lang.Object attach)
Register the given channel with the given selector for the given operations of interest |
void |
run()
|
void |
startServer()
Start the server pool, processing threads and bind to the inet address |
void |
stopListening()
|
void |
stopServer()
Stop the server from processing and more TCP incoming requests |
| 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public NIOTcpServer(ListenCallback callback,
ThreadPool pool,
int bufferSize,
java.net.InetAddress bind,
int port,
long timeout)
| Method Detail |
public void run()
run in interface java.lang.Runnable
public void listen()
throws java.lang.Exception
java.lang.Exception
public void stopListening()
throws java.lang.Exception
java.lang.Exception
protected void registerChannel(java.nio.channels.Selector selector,
java.nio.channels.SelectableChannel channel,
int ops,
java.lang.Object attach)
throws java.lang.Exception
java.lang.Exception
protected void readDataFromSocket(java.nio.channels.SelectionKey key)
throws java.lang.Exception
key - A SelectionKey object associated with a channel determined by the selector to be ready for reading.
If the channel returns an EOF condition, it is closed here, which automatically invalidates the
associated key. The selector will then de-register the channel on the next select call.
java.lang.Exceptionpublic boolean isStarted()
public void startServer()
startServer in interface TcpServiceAPI
public void stopServer()
throws java.lang.Exception
stopServer in interface TcpServiceAPIjava.lang.Exception
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||