#include <connectionManager.h>
Inheritance diagram for ConnectionManager:
Public Member Functions | |
ConnectionManager () | |
virtual | ~ConnectionManager () |
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. | |
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 | |
void | new_connection (const PointerTo< Connection > &connection) |
This internal function is called whenever a new connection is established. | |
virtual void | connection_reset (const PointerTo< Connection > &connection)=0 |
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. | |
Protected Attributes | |
Connections | _connections |
Readers | _readers |
Writers | _writers |
PRLock * | _set_mutex |
Friends | |
class | ConnectionReader |
class | ConnectionWriter |
class | ConnectionListener |
class | Connection |
A ConnectionManager is used to establish and destroy TCP and UDP connections. Communication on these connections, once established, is handled via ConnectionReader, ConnectionWriter, and ConnectionListener.
This is actually an abstract class, since it does not define what to do when a connection is externally reset (i.e. closed on the other end, or dropped because of network errors). See QueuedConnectionManager.
Definition at line 68 of file connectionManager.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 44 of file connectionManager.cxx. References _readers. |
|
Definition at line 56 of file connectionManager.cxx. References _writers. |
|
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 _connections, and _set_mutex. Referenced by HTTPClient::test_connection(). |
|
Implemented in QueuedConnectionManager. Referenced by ConnectionReader::process_incoming_data(). |
|
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 _set_mutex, _writers, and writer(). |
|
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 _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. |
|
Definition at line 106 of file connectionManager.h. |
|
Definition at line 105 of file connectionManager.h. |
|
Definition at line 103 of file connectionManager.h. |
|
Definition at line 104 of file connectionManager.h. |
|
Definition at line 97 of file connectionManager.h. Referenced by close_connection(). |
|
Definition at line 98 of file connectionManager.h. Referenced by ConnectionManager(), and open_TCP_client_connection(). |
|
Definition at line 100 of file connectionManager.h. Referenced by close_connection(), and get_host_name(). |
|
Definition at line 99 of file connectionManager.h. Referenced by get_host_name(), and ~ConnectionManager(). |