Class ServerSocketComm

java.lang.Object
com.iizix.comm.ServerSocketComm
All Implemented Interfaces:
ISocketComm, IWorkerTimeout

public class ServerSocketComm extends Object implements ISocketComm
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
  • Field Details

  • Constructor Details

    • ServerSocketComm

      public 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

    • open

      public void open() throws IOException
      Opens the communication.
      Throws:
      IOException
    • process

      public void process(ByteBuffer buffer)
      Processes the SelectionKey as it has generated an event.
      Specified by:
      process in interface ISocketComm
      Parameters:
      buffer - The direct buffer allocated by the worker.
    • getState

      public ServerSocketComm.State getState()
      Gets the state of the connection.
    • isClosed

      public boolean isClosed()
      Checks if the connection is disposed of.
    • close

      public boolean close()
      Call this method to close the socket. Same as close(true/false).
      Returns:
      true if closed, false if already closed.
    • close

      public boolean close(boolean rightNow)
      Call this method to close the socket.
      Specified by:
      close in interface ISocketComm
      Parameters:
      rightNow - In thins implementation this flag has no effect.
      Returns:
      true if closed, false if already closed.
    • getRemainingTimeout

      public long getRemainingTimeout(long timeNow)
      Gets the socket timeout value remaining.

      The Server Socket Communication always returns -1 for indefinite timeout.

      Specified by:
      getRemainingTimeout in interface IWorkerTimeout
      Parameters:
      timeNow - The current time.
      Returns:
      Time in milliseconds until timeout, NOTE! -1 for indefinite timeout.
    • checkTimeout

      public 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:
      checkTimeout in interface IWorkerTimeout
      Parameters:
      timeNow - The current time.