Panda3D
|
This flavor of ConnectionManager will queue up all of the reset-connection messages from the ConnectionReaders and ConnectionWriters and report them to the client on demand. More...
#include "queuedConnectionManager.h"
Public Member Functions | |
bool | close_connection (const PT(Connection)&connection) |
Terminates a UDP or TCP socket previously opened. | |
int | get_current_queue_size () const |
int | get_max_queue_size () const |
bool | get_overflow_flag () const |
bool | get_reset_connection (PT(Connection)&connection) |
If a previous call to reset_connection_available() returned true, this function will return information about the newly reset connection. | |
PT (Connection) open_UDP_connection(int port=0) | |
PT (Connection) open_TCP_server_rendezvous(const NetAddress &address | |
PT (Connection) open_TCP_client_connection(const NetAddress &address | |
PT (Connection) open_TCP_server_rendezvous(const string &hostname | |
PT (Connection) open_TCP_client_connection(const string &hostname | |
PT (Connection) open_TCP_server_rendezvous(int port | |
bool | reset_connection_available () const |
Returns true if one of the readers/writers/listeners reported a connection reset recently. | |
void | reset_overflow_flag () |
void | set_max_queue_size (int max_size) |
Static Public Member Functions | |
static 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. | |
Public Attributes | |
int | backlog |
int int | backlog |
int | port |
int | timeout_ms |
int int | timeout_ms |
Protected Types | |
typedef phash_set< PT(Connection) > | Connections |
typedef phash_set < ConnectionReader *, pointer_hash > | Readers |
typedef phash_set < ConnectionWriter *, pointer_hash > | Writers |
Protected Member Functions | |
void | add_reader (ConnectionReader *reader) |
This internal function is called by ConnectionReader when it is constructed. | |
void | add_writer (ConnectionWriter *writer) |
This internal function is called by ConnectionWriter when it is constructed. | |
virtual void | connection_reset (const PT(Connection)&connection, bool okflag) |
An internal function called by the ConnectionReader, ConnectionWriter, or ConnectionListener when a connection has been externally reset. | |
bool | enqueue_thing (const PT(Connection)&thing) |
bool | enqueue_unique_thing (const PT(Connection)&thing) |
virtual void | flush_read_connection (Connection *connection) |
An internal function called by ConnectionWriter only when a write failure has occurred. | |
bool | get_thing (PT(Connection)&thing) |
void | new_connection (const PT(Connection)&connection) |
This internal function is called whenever a new connection is established. | |
void | remove_reader (ConnectionReader *reader) |
This internal function is called by ConnectionReader when it is destructed. | |
void | remove_writer (ConnectionWriter *writer) |
This internal function is called by ConnectionWriter when it is destructed. | |
bool | thing_available () const |
Protected Attributes | |
Connections | _connections |
Readers | _readers |
LightMutex | _set_mutex |
Writers | _writers |
This flavor of ConnectionManager will queue up all of the reset-connection messages from the ConnectionReaders and ConnectionWriters and report them to the client on demand.
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 39 of file queuedConnectionManager.h.
void ConnectionManager::add_reader | ( | ConnectionReader * | reader | ) | [protected, inherited] |
This internal function is called by ConnectionReader when it is constructed.
Definition at line 437 of file connectionManager.cxx.
Referenced by ConnectionReader::ConnectionReader().
void ConnectionManager::add_writer | ( | ConnectionWriter * | writer | ) | [protected, inherited] |
This internal function is called by ConnectionWriter when it is constructed.
Definition at line 461 of file connectionManager.cxx.
Referenced by ConnectionWriter::ConnectionWriter().
bool ConnectionManager::close_connection | ( | const PT(Connection)& | connection | ) | [inherited] |
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 300 of file connectionManager.cxx.
References Socket_IP::Close(), Connection::flush(), and Connection::get_socket().
Referenced by PStatServer::connection_reset(), ConnectionManager::connection_reset(), PStatReader::lost_connection(), and MayaToEggServer::poll().
void QueuedConnectionManager::connection_reset | ( | const PT(Connection)& | connection, |
bool | okflag | ||
) | [protected, virtual] |
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.
Reimplemented from ConnectionManager.
Definition at line 97 of file queuedConnectionManager.cxx.
References QueuedReturn< PT(Connection) >::enqueue_unique_thing().
void ConnectionManager::flush_read_connection | ( | Connection * | connection | ) | [protected, virtual, inherited] |
An internal function called by ConnectionWriter only when a write failure has occurred.
This method ensures that all of the read data has been flushed from the pipe before the connection is fully removed.
Definition at line 376 of file connectionManager.cxx.
References Socket_IP::Close(), and Connection::get_socket().
string ConnectionManager::get_host_name | ( | ) | [static, inherited] |
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.
bool QueuedConnectionManager::get_reset_connection | ( | PT(Connection)& | connection | ) |
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 82 of file queuedConnectionManager.cxx.
References QueuedReturn< PT(Connection) >::get_thing().
Referenced by MayaToEggServer::poll().
void ConnectionManager::new_connection | ( | const PT(Connection)& | connection | ) | [protected, inherited] |
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 362 of file connectionManager.cxx.
Referenced by ConnectionListener::process_incoming_data().
void ConnectionManager::remove_reader | ( | ConnectionReader * | reader | ) | [protected, inherited] |
This internal function is called by ConnectionReader when it is destructed.
Definition at line 449 of file connectionManager.cxx.
void ConnectionManager::remove_writer | ( | ConnectionWriter * | writer | ) | [protected, inherited] |
This internal function is called by ConnectionWriter when it is destructed.
Definition at line 473 of file connectionManager.cxx.
bool QueuedConnectionManager::reset_connection_available | ( | ) | const |
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 55 of file queuedConnectionManager.cxx.
References QueuedReturn< PT(Connection) >::thing_available().
Referenced by MayaToEggServer::poll().