Class SocketListener
- java.lang.Object
-
- org.simpleframework.transport.connect.SocketListener
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class SocketListener extends java.lang.Object implements java.io.Closeable
TheSocketListener
object is represents the interface to the server that the clients can connect to. This is responsible for making call backs to theSocketAcceptor
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
Fields Modifier and Type Field Description private SocketAcceptor
acceptor
This is the acceptor that is used to accept the connections.private Reactor
reactor
This is the reactor used to notify the acceptor of sockets.
-
Constructor Summary
Constructors Constructor Description SocketListener(java.net.SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer)
Constructor for theSocketListener
object.SocketListener(java.net.SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer, javax.net.ssl.SSLContext context)
Constructor for theSocketListener
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This is used to close the connection and the server socket used to accept connections.java.net.SocketAddress
getAddress()
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 Detail
-
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 Detail
-
SocketListener
public SocketListener(java.net.SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer) throws java.io.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:
java.io.IOException
-
SocketListener
public SocketListener(java.net.SocketAddress address, SocketProcessor processor, TraceAnalyzer analyzer, javax.net.ssl.SSLContext context) throws java.io.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:
java.io.IOException
-
-
Method Detail
-
getAddress
public java.net.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 java.io.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:
java.io.IOException
-
close
public void close() throws java.io.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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-