Class SocketListener
java.lang.Object
org.simpleframework.transport.connect.SocketListener
- All Implemented Interfaces:
Closeable
,AutoCloseable
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final SocketAcceptor
This is the acceptor that is used to accept the connections.private final Reactor
This is the reactor used to notify the acceptor of sockets. -
Constructor Summary
ConstructorsConstructorDescriptionSocketListener
(SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer) Constructor for theSocketListener
object.SocketListener
(SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer, SSLContext context) Constructor for theSocketListener
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is used to close the connection and the server socket used to accept connections.This is used to acquire the local socket address that this is listening to.void
process()
This is used to register the socket acceptor to listen for new connections that are ready to be accepted.
-
Field Details
-
acceptor
This is the acceptor that is used to accept the connections. -
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 theSocketListener
object. This needs a socket address and a processor to hand created sockets to. This creates aReactor
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 socketsprocessor
- this is the processor that sockets are handed toanalyzer
- 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 theSocketListener
object. This needs a socket address and a processor to hand created sockets to. This creates aReactor
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 socketsprocessor
- this is the processor that sockets are handed toanalyzer
- this is used to create a trace to monitor eventscontext
- this is the SSL context used for secure HTTPS- Throws:
IOException
-
-
Method Details
-
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
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
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-