#include <queuedConnectionManager.h>
Inheritance diagram for QueuedConnectionManager:
Public Member Functions | |
QueuedConnectionManager () | |
~QueuedConnectionManager () | |
bool | reset_connection_available () const |
Returns true if one of the readers/writers/listeners reported a connection reset recently. | |
bool | get_reset_connection (PointerTo< Connection > &connection) |
If a previous call to reset_connection_available() returned true, this function will return information about the newly reset connection. | |
PointerTo< Connection > | open_UDP_connection (int port=0) |
Opens a socket for sending and/or receiving UDP packets. | |
PointerTo< Connection > | open_TCP_server_rendezvous (int port, int backlog) |
Creates a socket to be used as a rendezvous socket for a server to listen for TCP connections. | |
PointerTo< Connection > | open_TCP_client_connection (const NetAddress &address, int timeout_ms) |
Attempts to establish a TCP client connection to a server at the indicated address. | |
PointerTo< Connection > | open_TCP_client_connection (const string &hostname, int port, int timeout_ms) |
This is a shorthand version of the function to directly establish communcations to a named host and port. | |
bool | close_connection (const PointerTo< Connection > &connection) |
Terminates a UDP or TCP socket previously opened. | |
void | set_max_queue_size (int max_size) |
int | get_max_queue_size () const |
int | get_current_queue_size () const |
Static Public Member Functions | |
string | get_host_name () |
Returns the name of this particular machine on the network, if available, or the empty string if the hostname cannot be determined. | |
Protected Types | |
typedef pset< PointerTo< Connection > > | Connections |
typedef pset< ConnectionReader * > | Readers |
typedef pset< ConnectionWriter * > | Writers |
Protected Member Functions | |
virtual void | connection_reset (const PointerTo< Connection > &connection) |
An internal function called by the ConnectionReader, ConnectionWriter, or ConnectionListener when a connection has been externally reset. | |
void | new_connection (const PointerTo< Connection > &connection) |
This internal function is called whenever a new connection is established. | |
void | add_reader (ConnectionReader *reader) |
This internal function is called by ConnectionReader when it is constructed. | |
void | remove_reader (ConnectionReader *reader) |
This internal function is called by ConnectionReader when it is destructed. | |
void | add_writer (ConnectionWriter *writer) |
This internal function is called by ConnectionWriter when it is constructed. | |
void | remove_writer (ConnectionWriter *writer) |
This internal function is called by ConnectionWriter when it is destructed. | |
bool | thing_available () const |
bool | get_thing (PointerTo< Connection > &thing) |
bool | enqueue_thing (const PointerTo< Connection > &thing) |
bool | enqueue_unique_thing (const PointerTo< Connection > &thing) |
Protected Attributes | |
Connections | _connections |
Readers | _readers |
Writers | _writers |
PRLock * | _set_mutex |
When a reset connection has been discovered via reset_connection_available()/get_reset_connection(), it is still the responsibility of the client to call close_connection() on that connection to free up its resources.
Definition at line 60 of file queuedConnectionManager.h.
|
Definition at line 94 of file connectionManager.h. |
|
Definition at line 95 of file connectionManager.h. |
|
Definition at line 96 of file connectionManager.h. |
|
Definition at line 34 of file queuedConnectionManager.cxx. |
|
Definition at line 45 of file queuedConnectionManager.cxx. References QueuedReturn< PointerTo< Connection > >::thing_available(). |
|
This internal function is called by ConnectionReader when it is constructed.
Definition at line 386 of file connectionManager.cxx. |
|
This internal function is called by ConnectionWriter when it is constructed.
Definition at line 420 of file connectionManager.cxx. |
|
Terminates a UDP or TCP socket previously opened. This also removes it from any associated ConnectionReader or ConnectionListeners. The socket itself may not be immediately closed--it will not be closed until all outstanding pointers to it are cleared, including any pointers remaining in NetDatagrams recently received from the socket. The return value is true if the connection was marked to be closed, or false if close_connection() had already been called (or the connection did not belong to this ConnectionManager). In neither case can you infer anything about whether the connection has actually* been closed yet based on the return value. Definition at line 294 of file connectionManager.cxx. References ConnectionManager::_connections, and ConnectionManager::_set_mutex. Referenced by HTTPClient::test_connection(). |
|
An internal function called by the ConnectionReader, ConnectionWriter, or ConnectionListener when a connection has been externally reset. This adds the connection to the queue of those which have recently been reset. Implements ConnectionManager. Definition at line 150 of file queuedConnectionManager.cxx. |
|
Adds a new thing to the queue for later retrieval. Returns true if successful, false if the queue is full (i.e. has reached _max_queue_size). |
|
The same as enqueue_thing(), except the queue is first checked that it doesn't already have something like thing. The return value is true if the enqueue operation was successful, false if the queue was full or the thing was already on the queue. |
|
Returns the current number of things in the queue.
|
|
Returns the name of this particular machine on the network, if available, or the empty string if the hostname cannot be determined.
Definition at line 343 of file connectionManager.cxx. References ConnectionManager::_set_mutex, ConnectionManager::_writers, and writer(). |
|
Returns the maximum size the queue is allowed to grow to. See set_max_queue_size(). |
|
If a previous call to reset_connection_available() returned true, this function will return information about the newly reset connection. Only connections which were externally reset are certain to appear in this list. Those which were explicitly closed via a call to close_connection() may or may not be reported. Furthermore, it is the responsibility of the caller to subsequently call close_connection() with any connection reported reset by this call. (There is no harm in calling close_connection() more than once on a given socket.) The return value is true if a connection was successfully returned, or false if there was, in fact, no reset connection. (This may happen if there are multiple threads accessing the QueuedConnectionManager). Definition at line 128 of file queuedConnectionManager.cxx. |
|
If a previous call to thing_available() returned true, this function will return the thing that has become available. The return value is true if a thing was successfully returned, or false if there was, in fact, no thing available. (This may happen if there are multiple threads accessing the QueuedReturn). Referenced by reset_connection_available(). |
|
This internal function is called whenever a new connection is established. It allows the ConnectionManager to save all of the pointers to open connections so they can't be inadvertently deleted until close_connection() is called. Definition at line 369 of file connectionManager.cxx. |
|
This is a shorthand version of the function to directly establish communcations to a named host and port.
Definition at line 247 of file connectionManager.cxx. References ConnectionManager::_readers. |
|
Attempts to establish a TCP client connection to a server at the indicated address. If the connection is not established within timeout_ms milliseconds, a null connection is returned. Definition at line 205 of file connectionManager.cxx. References PT, and NetAddress::set_host(). |
|
Creates a socket to be used as a rendezvous socket for a server to listen for TCP connections. The socket returned by this call should only be added to a ConnectionListener (not to a generic ConnectionReader). backlog is the maximum length of the queue of pending connections. Definition at line 154 of file connectionManager.cxx. |
|
Opens a socket for sending and/or receiving UDP packets. If the port number is negative, it will not be bound to a socket; this is generally a pointless thing to do. If the port number is zero, a random socket will be chosen. Otherwise, the specified port number is used. Normally, you don't care what port a UDP connection is opened on, so you should use the default value of zero. Use a ConnectionReader and ConnectionWriter to handle the actual communication. Definition at line 100 of file connectionManager.cxx. |
|
This internal function is called by ConnectionReader when it is destructed.
Definition at line 403 of file connectionManager.cxx. |
|
This internal function is called by ConnectionWriter when it is destructed.
Definition at line 437 of file connectionManager.cxx. |
|
Returns true if one of the readers/writers/listeners reported a connection reset recently. If so, the particular connection that has been reset can be extracted via get_reset_connection(). Only connections which were externally reset are certain to appear in this list. Those which were explicitly closed via a call to close_connection() may or may not be reported. Furthermore, it is the responsibility of the caller to subsequently call close_connection() with any connection reported reset by this call. (There is no harm in calling close_connection() more than once on a given socket.) Definition at line 81 of file queuedConnectionManager.cxx. References QueuedReturn< PointerTo< Connection > >::get_thing(). |
|
Sets the maximum size the queue is allowed to grow to. This is primarily for a sanity check; this is a limit beyond which we can assume something bad has happened. It's also a crude check against unfortunate seg faults due to the queue filling up and quietly consuming all available memory. |
|
Returns true if a thing is available on the queue; call get_thing() to extract the thing.
Referenced by ~QueuedConnectionManager(). |
|
Definition at line 97 of file connectionManager.h. Referenced by ConnectionManager::close_connection(). |
|
Definition at line 98 of file connectionManager.h. Referenced by ConnectionManager::ConnectionManager(), and ConnectionManager::open_TCP_client_connection(). |
|
Definition at line 100 of file connectionManager.h. Referenced by ConnectionManager::close_connection(), and ConnectionManager::get_host_name(). |
|
Definition at line 99 of file connectionManager.h. Referenced by ConnectionManager::get_host_name(), and ConnectionManager::~ConnectionManager(). |