Class SocketListener

java.lang.Object
org.simpleframework.transport.connect.SocketListener
All Implemented Interfaces:
Closeable, AutoCloseable

class SocketListener extends Object implements Closeable
The SocketListener object is represents the interface to the server that the clients can connect to. This is responsible for making call backs to the SocketAcceptor when there is a new connection waiting to be accepted. When the connection is to be closed the interface object can be closed.
  • Field Details

    • acceptor

      private final SocketAcceptor acceptor
      This is the acceptor that is used to accept the connections.
    • reactor

      private final Reactor reactor
      This is the reactor used to notify the acceptor of sockets.
  • Constructor Details

    • SocketListener

      public SocketListener(SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer) throws IOException
      Constructor for the SocketListener object. This needs a socket address and a processor to hand created sockets to. This creates a Reactor which will notify the acceptor when there is a new connection waiting to be accepted.
      Parameters:
      address - this is the address to listen for new sockets
      processor - this is the processor that sockets are handed to
      analyzer - this is used to create a trace to monitor events
      Throws:
      IOException
    • SocketListener

      public SocketListener(SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer, SSLContext context) throws IOException
      Constructor for the SocketListener object. This needs a socket address and a processor to hand created sockets to. This creates a Reactor which will notify the acceptor when there is a new connection waiting to be accepted.
      Parameters:
      address - this is the address to listen for new sockets
      processor - this is the processor that sockets are handed to
      analyzer - this is used to create a trace to monitor events
      context - this is the SSL context used for secure HTTPS
      Throws:
      IOException
  • Method Details

    • getAddress

      public SocketAddress getAddress()
      This is used to acquire the local socket address that this is listening to. This required in case the socket address that is specified is an emphemeral address, that is an address that is assigned dynamically when a port of 0 is specified.
      Returns:
      this returns the address for the listening address
    • process

      public void process() throws IOException
      This is used to register the socket acceptor to listen for new connections that are ready to be accepted. Once this is registered it will remain registered until the interface is closed, at which point the socket is closed.
      Throws:
      IOException
    • close

      public void close() throws IOException
      This is used to close the connection and the server socket used to accept connections. This will perform a close of the connected server socket and the dispatching thread.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException