Poco::RemotingNG::TCP

class ConnectionManager

File Information

Library: RemotingNG/TCP
Package: TCP
Header: Poco/RemotingNG/TCP/ConnectionManager.h

Description

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 Summary

Member Functions: createConnection, defaultManager, findConnection, getConnection, getHandshakeTimeout, getIdleTimeout, registerConnection, setHandshakeTimeout, setIdleTimeout, shutdown, threadPool, unregisterConnection

Constructors

ConnectionManager

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

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.

Destructor

~ConnectionManager

~ConnectionManager();

Destroys the ConnectionManager.

Member Functions

defaultManager static

static ConnectionManager & defaultManager();

Returns the default ConnectionManager instance.

findConnection

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.

getConnection

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.

getHandshakeTimeout inline

Poco::Timespan getHandshakeTimeout() const;

Returns the timeout for the initial connection handshake.

getIdleTimeout inline

Poco::Timespan getIdleTimeout() const;

Returns the idle connection timeout.

registerConnection

void registerConnection(
    Connection::Ptr pConnection
);

Registers an existing connection.

setHandshakeTimeout

void setHandshakeTimeout(
    Poco::Timespan timeout
);

Sets the timeout for the initial connection handshake.

setIdleTimeout

void setIdleTimeout(
    Poco::Timespan timeout
);

Sets the timeout after an idle connection is closed.

shutdown

void shutdown();

Closes all connections.

threadPool inline

ThreadPool & threadPool();

Returns a reference to the ConnectionManager's thread pool.

unregisterConnection

void unregisterConnection(
    Connection::Ptr pConnection
);

Unregisters an existing connection.

createConnection protected

Connection::Ptr createConnection(
    const Poco::URI & endpointURI
);