14 #ifndef CONNECTIONMANAGER_H 15 #define CONNECTIONMANAGER_H 46 PT(
Connection) open_UDP_connection(uint16_t port = 0);
47 PT(
Connection) open_UDP_connection(
const std::string &hostname, uint16_t port,
bool for_broadcast =
false);
49 BLOCKING PT(
Connection) open_TCP_server_rendezvous(uint16_t port,
int backlog);
50 BLOCKING PT(
Connection) open_TCP_server_rendezvous(
const std::string &hostname,
51 uint16_t port,
int backlog);
56 BLOCKING PT(
Connection) open_TCP_client_connection(
const std::string &hostname,
57 uint16_t port,
int timeout_ms);
59 bool close_connection(
const PT(
Connection) &connection);
60 BLOCKING
bool wait_for_readers(
double timeout);
62 static std::string get_host_name();
66 const std::string &get_name()
const {
return _name; }
67 const std::string &get_mac_address()
const {
return _mac_address; }
68 bool has_ip()
const {
return (_flags & F_has_ip) != 0; }
69 const NetAddress &get_ip()
const {
return _ip; }
70 bool has_netmask()
const {
return (_flags & F_has_netmask) != 0; }
71 const NetAddress &get_netmask()
const {
return _netmask; }
72 bool has_broadcast()
const {
return (_flags & F_has_broadcast) != 0; }
73 const NetAddress &get_broadcast()
const {
return _broadcast; }
74 bool has_p2p()
const {
return (_flags & F_has_p2p) != 0; }
75 const NetAddress &get_p2p()
const {
return _p2p; }
77 void output(std::ostream &out)
const;
81 void set_name(
const std::string &name) { _name = name; }
82 void set_mac_address(
const std::string &mac_address) { _mac_address = mac_address; }
83 void set_ip(
const NetAddress &ip) { _ip = ip; _flags |= F_has_ip; }
84 void set_netmask(
const NetAddress &ip) { _netmask = ip; _flags |= F_has_netmask; }
85 void set_broadcast(
const NetAddress &ip) { _broadcast = ip; _flags |= F_has_broadcast; }
86 void set_p2p(
const NetAddress &ip) { _p2p = ip; _flags |= F_has_p2p; }
90 std::string _mac_address;
100 F_has_netmask = 0x002,
101 F_has_broadcast = 0x004,
106 void scan_interfaces();
107 size_t get_num_interfaces();
108 const Interface &get_interface(
size_t n);
109 MAKE_SEQ(get_interfaces, get_num_interfaces, get_interface);
111 MAKE_PROPERTY(host_name, get_host_name);
112 MAKE_SEQ_PROPERTY(interfaces, get_num_interfaces, get_interface);
115 void new_connection(
const PT(
Connection) &connection);
116 virtual void flush_read_connection(
Connection *connection);
117 virtual void connection_reset(
const PT(
Connection) &connection,
125 std::string format_mac_address(
const unsigned char *data,
size_t data_size);
127 typedef phash_set< PT(
Connection) > Connections;
128 typedef phash_set<ConnectionReader *, pointer_hash> Readers;
129 typedef phash_set<ConnectionWriter *, pointer_hash> Writers;
130 Connections _connections;
137 bool _interfaces_scanned;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The primary interface to the low-level networking layer in this package.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for a family of classes that listen for activity on a socket and respo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a standard, non-reentrant mutex, similar to the Mutex class.
Represents a single TCP or UDP socket for input or output.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a special kind of ConnectionReader that waits for activity on a rendezvous port and accepts a...
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.