public class SocketConnection extends Object implements Connection
SocketConnection
is used to manage connections
from a server socket. In order to achieve this it spawns a task
to listen for incoming connect requests. When a TCP connection
request arrives it hands off the SocketChannel
to
the SocketProcessor
which processes the request.
This handles connections from a ServerSocketChannel
object so that features such as SSL can be used by a server that
uses this package. The background acceptor process will terminate
if the connection is closed.
SocketProcessor
Constructor and Description |
---|
SocketConnection(SocketProcessor processor)
Constructor for the
SocketConnection object. |
SocketConnection(SocketProcessor processor,
TraceAnalyzer analyzer)
Constructor for the
SocketConnection object. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This is used to close the connection and the server socket
used to accept connections.
|
SocketAddress |
connect(SocketAddress address)
This creates a new background task that will listen to the
specified
ServerAddress for incoming TCP connect
requests. |
SocketAddress |
connect(SocketAddress address,
SSLContext context)
This creates a new background task that will listen to the
specified
ServerAddress for incoming TCP connect
requests. |
public SocketConnection(SocketProcessor processor) throws IOException
SocketConnection
object. This
will create a new connection that accepts incoming connections
and hands these connections as Socket
objects
to the specified connector. This in turn will deliver request
and response objects to the internal container.processor
- this is the connector that receives requestsIOException
public SocketConnection(SocketProcessor processor, TraceAnalyzer analyzer) throws IOException
SocketConnection
object. This
will create a new connection that accepts incoming connections
and hands these connections as Socket
objects
to the specified processor. This in turn will deliver request
and response objects to the internal container.processor
- this is the connector that receives requestsanalyzer
- this is used to create a trace for the socketIOException
public SocketAddress connect(SocketAddress address) throws IOException
ServerAddress
for incoming TCP connect
requests. When an connection is accepted it is handed to the
internal socket connector.connect
in interface Connection
address
- this is the address used to accept connectionsIOException
public SocketAddress connect(SocketAddress address, SSLContext context) throws IOException
ServerAddress
for incoming TCP connect
requests. When an connection is accepted it is handed to the
internal socket connector.connect
in interface Connection
address
- this is the address used to accept connectionscontext
- this is used for secure SSL connectionsIOException
public void close() throws IOException
connect
method. The connection can be
reused after the existing server sockets have been closed.close
in interface Closeable
close
in interface AutoCloseable
IOException
- thrown if there is a problem closingCopyright © 2022. All rights reserved.