ConnectionManager

from panda3d.net import ConnectionManager
class ConnectionManager

Bases: DTOOL_SUPER_BASE

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 diagram

Inheritance diagram of ConnectionManager

class Interface

Bases: DTOOL_SUPER_BASE

__init__(*args, **kwargs)
getBroadcast()

C++ Interface: get_broadcast(Interface self)

getIp()

C++ Interface: get_ip(Interface self)

getMacAddress()

C++ Interface: get_mac_address(Interface self)

getName()

C++ Interface: get_name(Interface self)

getNetmask()

C++ Interface: get_netmask(Interface self)

getP2p()

C++ Interface: get_p2p(Interface self)

get_broadcast()

C++ Interface: get_broadcast(Interface self)

get_ip()

C++ Interface: get_ip(Interface self)

get_mac_address()

C++ Interface: get_mac_address(Interface self)

get_name()

C++ Interface: get_name(Interface self)

get_netmask()

C++ Interface: get_netmask(Interface self)

get_p2p()

C++ Interface: get_p2p(Interface self)

hasBroadcast()

C++ Interface: has_broadcast(Interface self)

hasIp()

C++ Interface: has_ip(Interface self)

hasNetmask()

C++ Interface: has_netmask(Interface self)

hasP2p()

C++ Interface: has_p2p(Interface self)

has_broadcast()

C++ Interface: has_broadcast(Interface self)

has_ip()

C++ Interface: has_ip(Interface self)

has_netmask()

C++ Interface: has_netmask(Interface self)

has_p2p()

C++ Interface: has_p2p(Interface self)

output()

C++ Interface: output(Interface self, ostream out)

/**

*/

__init__(*args, **kwargs)
closeConnection()

C++ Interface: close_connection(const ConnectionManager self, const Connection connection)

/**
  • 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.

*/

close_connection()

C++ Interface: close_connection(const ConnectionManager self, const Connection connection)

/**
  • 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()

C++ Interface: 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.

*/

getInterface()

C++ Interface: get_interface(const ConnectionManager self, int n)

/**
  • Returns the nth usable network interface detected on this machine.

  • See scan_interfaces() to repopulate this list.

*/

getInterfaces()
getNumInterfaces()

C++ Interface: get_num_interfaces(const ConnectionManager self)

/**
  • This returns the number of usable network interfaces detected on this

  • machine. See scan_interfaces() to repopulate this list.

*/

get_host_name()

C++ Interface: 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.

*/

get_interface()

C++ Interface: get_interface(const ConnectionManager self, int n)

/**
  • Returns the nth usable network interface detected on this machine.

  • See scan_interfaces() to repopulate this list.

*/

get_interfaces()
get_num_interfaces()

C++ Interface: get_num_interfaces(const ConnectionManager self)

/**
  • This returns the number of usable network interfaces detected on this

  • machine. See scan_interfaces() to repopulate this list.

*/

host_name = 'runnervmf4ws1'
interfaces
openTCPClientConnection()

C++ Interface: open_TCP_client_connection(const ConnectionManager self, const NetAddress address, int timeout_ms) open_TCP_client_connection(const ConnectionManager self, str hostname, int port, int timeout_ms)

/**
  • 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.

*/

/**
  • This is a shorthand version of the function to directly establish

  • communications to a named host and port.

*/

openTCPServerRendezvous()

C++ Interface: open_TCP_server_rendezvous(const ConnectionManager self, const NetAddress address, int backlog) open_TCP_server_rendezvous(const ConnectionManager self, int port, int backlog) open_TCP_server_rendezvous(const ConnectionManager self, str hostname, int port, int backlog)

/**
  • 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, both IPv4 and IPv6.

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

*/

/**
  • 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.

*/

/**
  • 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.

*/

openUDPConnection()

C++ Interface: open_UDP_connection(const ConnectionManager self) open_UDP_connection(const ConnectionManager self, int port) open_UDP_connection(const ConnectionManager self, str hostname, int port, bool for_broadcast)

/**
  • 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.

*/

/**
  • 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.

  • This variant accepts both a hostname and port to listen on a particular

  • interface; if the hostname is empty, all interfaces will be available,

  • both IPv4 and IPv6.

  • If for_broadcast is true, this UDP connection will be configured to send

  • and/or receive messages on the broadcast address (255.255.255.255);

  • otherwise, these messages may be automatically filtered by the OS.

  • Use a ConnectionReader and ConnectionWriter to handle the actual

  • communication.

*/

open_TCP_client_connection()

C++ Interface: open_TCP_client_connection(const ConnectionManager self, const NetAddress address, int timeout_ms) open_TCP_client_connection(const ConnectionManager self, str hostname, int port, int timeout_ms)

/**
  • 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.

*/

/**
  • This is a shorthand version of the function to directly establish

  • communications to a named host and port.

*/

open_TCP_server_rendezvous()

C++ Interface: open_TCP_server_rendezvous(const ConnectionManager self, const NetAddress address, int backlog) open_TCP_server_rendezvous(const ConnectionManager self, int port, int backlog) open_TCP_server_rendezvous(const ConnectionManager self, str hostname, int port, int backlog)

/**
  • 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, both IPv4 and IPv6.

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

*/

/**
  • 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.

*/

/**
  • 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.

*/

open_UDP_connection()

C++ Interface: open_UDP_connection(const ConnectionManager self) open_UDP_connection(const ConnectionManager self, int port) open_UDP_connection(const ConnectionManager self, str hostname, int port, bool for_broadcast)

/**
  • 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.

*/

/**
  • 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.

  • This variant accepts both a hostname and port to listen on a particular

  • interface; if the hostname is empty, all interfaces will be available,

  • both IPv4 and IPv6.

  • If for_broadcast is true, this UDP connection will be configured to send

  • and/or receive messages on the broadcast address (255.255.255.255);

  • otherwise, these messages may be automatically filtered by the OS.

  • Use a ConnectionReader and ConnectionWriter to handle the actual

  • communication.

*/

scanInterfaces()

C++ Interface: scan_interfaces(const ConnectionManager self)

/**
  • Repopulates the list reported by get_num_interface()/get_interface(). It

  • is not necessary to call this explicitly, unless you want to re-determine

  • the connected interfaces (for instance, if you suspect the hardware has

  • recently changed).

*/

scan_interfaces()

C++ Interface: scan_interfaces(const ConnectionManager self)

/**
  • Repopulates the list reported by get_num_interface()/get_interface(). It

  • is not necessary to call this explicitly, unless you want to re-determine

  • the connected interfaces (for instance, if you suspect the hardware has

  • recently changed).

*/

waitForReaders()

C++ Interface: wait_for_readers(const ConnectionManager self, double timeout)

/**
  • Blocks the process for timeout number of seconds, or until any data is

  • available on any of the non-threaded ConnectionReaders or

  • ConnectionListeners, whichever comes first. The return value is true if

  • there is data available (but you have to iterate through all readers to

  • find it), or false if the timeout occurred without any data.

  • If the timeout value is negative, this will block forever or until data is

  • available.

  • This only works if all ConnectionReaders and ConnectionListeners are non-

  • threaded. If any threaded ConnectionReaders are part of the

  • ConnectionManager, the timeout value is implicitly treated as 0.

*/

wait_for_readers()

C++ Interface: wait_for_readers(const ConnectionManager self, double timeout)

/**
  • Blocks the process for timeout number of seconds, or until any data is

  • available on any of the non-threaded ConnectionReaders or

  • ConnectionListeners, whichever comes first. The return value is true if

  • there is data available (but you have to iterate through all readers to

  • find it), or false if the timeout occurred without any data.

  • If the timeout value is negative, this will block forever or until data is

  • available.

  • This only works if all ConnectionReaders and ConnectionListeners are non-

  • threaded. If any threaded ConnectionReaders are part of the

  • ConnectionManager, the timeout value is implicitly treated as 0.

*/