Panda3D
Public Member Functions | Static Public Member Functions

QueuedConnectionManager Class Reference

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...

Inheritance diagram for QueuedConnectionManager:
ConnectionManager QueuedReturnPointerToConnection

List of all members.

Public Member Functions

 QueuedConnectionManager ()
bool closeConnection (Connection connection)
 Terminates a UDP or TCP socket previously opened.
int getCurrentQueueSize ()
int getMaxQueueSize ()
bool getOverflowFlag ()
bool getResetConnection (PointerToConnection connection)
 If a previous call to reset_connection_available() returned true, this function will return information about the newly reset connection.
Connection openTCPClientConnection (NetAddress const address, int timeout_ms)
 Attempts to establish a TCP client connection to a server at the indicated address.
Connection openTCPClientConnection (string hostname, int port, int timeout_ms)
 This is a shorthand version of the function to directly establish communications to a named host and port.
Connection openTCPServerRendezvous (int port, int backlog)
 Creates a socket to be used as a rendezvous socket for a server to listen for TCP connections.
Connection openTCPServerRendezvous (NetAddress const address, int backlog)
 Creates a socket to be used as a rendezvous socket for a server to listen for TCP connections.
Connection openTCPServerRendezvous (string hostname, int port, int backlog)
 Creates a socket to be used as a rendezvous socket for a server to listen for TCP connections.
Connection openUDPConnection (int port)
 Opens a socket for sending and/or receiving UDP packets.
Connection openUDPConnection ()
 Opens a socket for sending and/or receiving UDP packets.
bool resetConnectionAvailable ()
 Returns true if one of the readers/writers/listeners reported a connection reset recently.
 resetOverflowFlag ()
 setMaxQueueSize (int max_size)

Static Public Member Functions

static string getHostName ()
 Returns the name of this particular machine on the network, if available, or the empty string if the hostname cannot be determined.

Detailed Description

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.


Constructor & Destructor Documentation


Member Function Documentation

bool closeConnection ( 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.

int getCurrentQueueSize ( ) [inherited]
static string getHostName ( ) [static, inherited]

Returns the name of this particular machine on the network, if available, or the empty string if the hostname cannot be determined.

int getMaxQueueSize ( ) [inherited]
bool getOverflowFlag ( ) [inherited]
bool getResetConnection ( PointerToConnection  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).

Connection openTCPClientConnection ( string  hostname,
int  port,
int  timeout_ms 
) [inherited]

This is a shorthand version of the function to directly establish communications to a named host and port.

Connection openTCPClientConnection ( NetAddress const  address,
int  timeout_ms 
) [inherited]

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.

Connection openTCPServerRendezvous ( NetAddress const  address,
int  backlog 
) [inherited]

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).

This variant of this method accepts a NetAddress, which allows you to specify a specific interface to listen to.

backlog is the maximum length of the queue of pending connections.

Connection openTCPServerRendezvous ( string  hostname,
int  port,
int  backlog 
) [inherited]

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).

This variant of this method accepts a "hostname", which is usually just an IP address in dotted notation, and a port number. It will listen on the interface indicated by the IP address. If the IP address is empty string, it will listen on all interfaces.

backlog is the maximum length of the queue of pending connections.

Connection openTCPServerRendezvous ( int  port,
int  backlog 
) [inherited]

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).

This variant of this method accepts a single port, and will listen to that port on all available interfaces.

backlog is the maximum length of the queue of pending connections.

Connection openUDPConnection ( ) [inherited]

Opens a socket for sending and/or receiving UDP packets.

If the port number is greater than zero, the UDP connection will be opened for listening on the indicated port; otherwise, it will be useful only for sending.

Use a ConnectionReader and ConnectionWriter to handle the actual communication.

Connection openUDPConnection ( int  port) [inherited]

Opens a socket for sending and/or receiving UDP packets.

If the port number is greater than zero, the UDP connection will be opened for listening on the indicated port; otherwise, it will be useful only for sending.

Use a ConnectionReader and ConnectionWriter to handle the actual communication.

bool resetConnectionAvailable ( )

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.)

resetOverflowFlag ( ) [inherited]
setMaxQueueSize ( int  max_size) [inherited]
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties