Library: RemotingNG/TCP
Package: TCP
Header: Poco/RemotingNG/TCP/ConnectionManager.h
The ConnectionManager manages a collection of Connection objects.
Connection objects are either created by a ServerConnection as a result of an accepted connection request by the server, or by the ConnectionManager, in the case of client-side Connection objects.
For creation of Connection objects the ConnectionManager uses a SocketFactory.
A Poco::ThreadPool is used to obtain threads for driving the protocol on the client side, as well as for scheduling requests on the server and events on the client.
Member Functions: createConnection, defaultManager, findConnection, getConnection, getIdleTimeout, registerConnection, setIdleTimeout, shutdown, threadPool, unregisterConnection
ConnectionManager(
Poco::ThreadPool & threadPool = Poco::ThreadPool::defaultPool ()
);
Creates a ConnectionManager using the default SocketFactory.
Optionally, a Poco::ThreadPool can be specified if the default pool should not be used.
ConnectionManager(
SocketFactory::Ptr pSocketFactory,
Poco::ThreadPool & threadPool = Poco::ThreadPool::defaultPool ()
);
Creates a ConnectionManager using the given SocketFactory.
Optionally, a Poco::ThreadPool can be specified if the default pool should not be used.
Destroys the ConnectionManager.
static ConnectionManager & defaultManager();
Returns the default ConnectionManager instance.
Connection::Ptr findConnection(
const Poco::Net::SocketAddress & peerAddress
);
Searches for a connection to the given peer address.
If a connection exists, and the connection is in established state, it is returned. Otherwise, a null pointer is returned.
Connection::Ptr getConnection(
const Poco::URI & endpointURI
);
Searches for a connection to the given endpoint.
If a connection exists, and the connection is in established state, it is returned. Otherwise, a new connection to that endpoint is created.
Poco::Timespan getIdleTimeout() const;
Returns the idle connection timeout.
void registerConnection(
Connection::Ptr pConnection
);
Registers an existing connection.
void setIdleTimeout(
Poco::Timespan timeout
);
Sets the timeout after an idle connection is closed.
void shutdown();
Closes all connections.
ThreadPool & threadPool();
Returns a reference to the ConnectionManager's thread pool.
void unregisterConnection(
Connection::Ptr pConnection
);
Unregisters an existing connection.
Connection::Ptr createConnection(
const Poco::URI & endpointURI
);