Class SocketConnection
java.lang.Object
org.simpleframework.transport.connect.SocketConnection
- All Implemented Interfaces:
Closeable, AutoCloseable, Connection
The
SocketConnectionis 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 Server 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.
- Author:
- Niall Gallagher
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSocketConnection(Container container) Constructor for theSocketConnectionobject.SocketConnection(Server server) Constructor for theSocketConnectionobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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 specifiedServerAddressfor incoming TCP connect requests.connect(SocketAddress address, SSLContext context) This creates a new background task that will listen to the specifiedServerAddressfor incoming TCP connect requests.
-
Constructor Details
-
SocketConnection
Constructor for theSocketConnectionobject. This will create a new connection that accepts incoming connections and hands these connections asPipelineobjects to the specified processor. This in turn will deliver request and response objects to the internal container.- Parameters:
server- this is the processor that receives requests- Throws:
IOException
-
SocketConnection
Constructor for theSocketConnectionobject. This will create a new connection that accepts incoming connections and hands these connections asPipelineobjects to the specified processor. This in turn will deliver request and response objects to the internal container.- Parameters:
container- this is the container that receives requests- Throws:
IOException
-
-
Method Details
-
connect
This creates a new background task that will listen to the specifiedServerAddressfor incoming TCP connect requests. When an connection is accepted it is handed to the internalServerimplementation as a pipeline. The background task is a non daemon task to ensure the server is kept active, to terminate the connection this can be closed.- Specified by:
connectin 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 specifiedServerAddressfor incoming TCP connect requests. When an connection is accepted it is handed to the internalServerimplementation as a pipeline. The background task is a non daemon task to ensure the server is kept active, to terminate the connection this can be closed.- Specified by:
connectin 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 theconnectmethod. The connection can be reused after the existing server sockets have been closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- thrown if there is a problem closing
-