# ConnectionManager

from pandac.PandaModules import ConnectionManager

Class : ConnectionManager
Description : The primary interface to the low-level networking layer in this package. 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.
You may use this class directly if you don't care about tracking which connections have been unexpectedly closed; otherwise, you should use QueuedConnectionManager to get reports about these events (or derive your own class to handle these events properly).

## Inheritance:

ConnectionManager:

## Methods of ConnectionManager:

ConnectionManager (Constructor)
closeConnection
getHostName
openTCPClientConnection
openTCPServerRendezvous
openUDPConnection

ConnectionManager ConnectionManager::ConnectionManager(void); Description:

closeConnection bool ConnectionManager::close_connection(PointerTo< Connection > const &connection); Description: 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.

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

openTCPClientConnection PointerTo< Connection > ConnectionManager::open_TCP_client_connection(NetAddress const &address, int timeout_ms); Description: 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. Description: This is a shorthand version of the function to directly establish communications to a named host and port.

openTCPServerRendezvous PointerTo< Connection > ConnectionManager::open_TCP_server_rendezvous(int port, int backlog); Description: 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.

openUDPConnection PointerTo< Connection > ConnectionManager::open_UDP_connection(int port = (0)); Description: 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.