Class SocketAcceptor

All Implemented Interfaces:
IoAcceptor, IoService

public class SocketAcceptor extends BaseIoAcceptor
IoAcceptor for socket transport (TCP/IP).
  • Constructor Details

    • SocketAcceptor

      public SocketAcceptor()
      Create an acceptor with a single processing thread using a NewThreadExecutor
    • SocketAcceptor

      public SocketAcceptor(int processorCount, Executor executor)
      Create an acceptor with the desired number of processing threads
      Parameters:
      processorCount - Number of processing threads
      executor - Executor to use for launching threads
  • Method Details

    • bind

      public void bind(SocketAddress address, IoHandler handler, IoServiceConfig config) throws IOException
      Binds to the specified address and handles incoming connections with the specified handler. Backlog value is configured to the value of backlog property.
      Parameters:
      config - the configuration
      Throws:
      IOException - if failed to bind
    • unbind

      public void unbind(SocketAddress address)
      Description copied from interface: IoAcceptor
      Unbinds from the specified address and disconnects all clients connected there.
    • unbindAll

      public void unbindAll()
      Description copied from interface: IoAcceptor
      Unbinds all addresses which were bound by this acceptor.
    • getDefaultConfig

      public SocketAcceptorConfig getDefaultConfig()
      Description copied from interface: IoService
      Returns the default configuration which is used when you didn't specify any configuration.
    • setDefaultConfig

      public void setDefaultConfig(SocketAcceptorConfig defaultConfig)
      Sets the config this acceptor will use by default.
      Parameters:
      defaultConfig - the default config.
      Throws:
      NullPointerException - if the specified value is null.