Package com.iizix.comm
Class ServerSocketComm
java.lang.Object
com.iizix.comm.ServerSocketComm
- All Implemented Interfaces:
- ISocketComm,- IWorkerTimeout
The ServerSocketComm class is used to open a plain server socket with an optional bind address. All responses is sent to the ServerSocketCommListener.
- Author:
- Christopher Mindus
- Nested Class SummaryNested ClassesModifier and TypeClassDescription- static enumThe state of the communication link.
- Field SummaryFields
- Constructor SummaryConstructorsConstructorDescription- ServerSocketComm- (ServerSocketCommProps properties, Worker worker, ServerSocketCommListener listener) Creates a new Server Socket Communication channel as UNINITIALIZED.
- Method SummaryModifier and TypeMethodDescription- void- checkTimeout- (long timeNow) Performs a timeout check for the socket channel.- boolean- close()Call this method to close the socket.- boolean- close- (boolean rightNow) Call this method to close the socket.- long- getRemainingTimeout- (long timeNow) Gets the socket timeout value remaining.- getState()Gets the state of the connection.- boolean- isClosed()Checks if the connection is disposed of.- void- open()Opens the communication.- void- process- (ByteBuffer buffer) Processes the SelectionKey as it has generated an event.
- Field Details- propertiesThe properties for the socket.
 
- Constructor Details- ServerSocketCommpublic ServerSocketComm- (ServerSocketCommProps properties, Worker worker, ServerSocketCommListener listener) Creates a new Server Socket Communication channel as UNINITIALIZED.- Parameters:
- properties- The server socket properties.
- worker- The worker thread for socket processing.
- listener- The listener for server socket events.
 
 
- Method Details- openOpens the communication.- Throws:
- IOException
 
- processProcesses the SelectionKey as it has generated an event.- Specified by:
- processin interface- ISocketComm
- Parameters:
- buffer- The direct buffer allocated by the worker.
 
- getStateGets the state of the connection.
- isClosedpublic boolean isClosed()Checks if the connection is disposed of.
- closepublic boolean close()Call this method to close the socket. Same as close(true/false).- Returns:
- true if closed, false if already closed.
 
- closepublic boolean close- (boolean rightNow) Call this method to close the socket.- Specified by:
- closein interface- ISocketComm
- Parameters:
- rightNow- In thins implementation this flag has no effect.
- Returns:
- true if closed, false if already closed.
 
- getRemainingTimeoutpublic long getRemainingTimeout- (long timeNow) Gets the socket timeout value remaining.- The Server Socket Communication always returns -1 for indefinite timeout. - Specified by:
- getRemainingTimeoutin interface- IWorkerTimeout
- Parameters:
- timeNow- The current time.
- Returns:
- Time in milliseconds until timeout, NOTE! -1 for indefinite timeout.
 
- checkTimeoutpublic void checkTimeout- (long timeNow) Performs a timeout check for the socket channel. This is called to all channels, so each channel must check its own state.- The Server Socket Communication performs nothing for this method. - Specified by:
- checkTimeoutin interface- IWorkerTimeout
- Parameters:
- timeNow- The current time.