Class SocketConnection
java.lang.Object
org.simpleframework.transport.connect.SocketConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Connection
The
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
This is used to determine if the connection has been closed.private SocketListenerManager
This is used to maintain the active connection end points.private SocketProcessor
The processor is used to process connected HTTP pipelines. -
Constructor Summary
ConstructorsConstructorDescriptionSocketConnection
(SocketProcessor processor) Constructor for theSocketConnection
object.SocketConnection
(SocketProcessor processor, TraceAnalyzer analyzer) Constructor for theSocketConnection
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is used to close the connection and the server socket used to accept connections.connect
(SocketAddress address) This creates a new background task that will listen to the specifiedServerAddress
for incoming TCP connect requests.connect
(SocketAddress address, SSLContext context) This creates a new background task that will listen to the specifiedServerAddress
for incoming TCP connect requests.
-
Field Details
-
manager
This is used to maintain the active connection end points. -
processor
The processor is used to process connected HTTP pipelines. -
closed
private boolean closedThis is used to determine if the connection has been closed.
-
-
Constructor Details
-
SocketConnection
Constructor for theSocketConnection
object. This will create a new connection that accepts incoming connections and hands these connections asSocket
objects to the specified connector. This in turn will deliver request and response objects to the internal container.- Parameters:
processor
- this is the connector that receives requests- Throws:
IOException
-
SocketConnection
Constructor for theSocketConnection
object. This will create a new connection that accepts incoming connections and hands these connections asSocket
objects to the specified processor. This in turn will deliver request and response objects to the internal container.- Parameters:
processor
- this is the connector that receives requestsanalyzer
- this is used to create a trace for the socket- Throws:
IOException
-
-
Method Details
-
connect
This creates a new background task that will listen to the specifiedServerAddress
for incoming TCP connect requests. When an connection is accepted it is handed to the internal socket connector.- Specified by:
connect
in interfaceConnection
- Parameters:
address
- this is the address used to accept connections- Returns:
- this returns the actual local address that is used
- Throws:
IOException
-
connect
This creates a new background task that will listen to the specifiedServerAddress
for incoming TCP connect requests. When an connection is accepted it is handed to the internal socket connector.- Specified by:
connect
in interfaceConnection
- Parameters:
address
- this is the address used to accept connectionscontext
- this is used for secure SSL connections- Returns:
- this returns the actual local address that is used
- Throws:
IOException
-
close
This is used to close the connection and the server socket used to accept connections. This will perform a close of all connected server sockets that have been created from using theconnect
method. The connection can be reused after the existing server sockets have been closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- thrown if there is a problem closing
-