Panda3D
netAddress.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file netAddress.h
10  * @author drose
11  * @date 2000-02-08
12  */
13 
14 #ifndef NETADDRESS_H
15 #define NETADDRESS_H
16 
17 #include "pandabase.h"
18 #include "numeric_types.h"
19 #include "socket_address.h"
20 
21 /**
22  * Represents a network address to which UDP packets may be sent or to which a
23  * TCP socket may be bound.
24  */
25 class EXPCL_PANDA_NET NetAddress {
26 PUBLISHED:
27  NetAddress();
28  NetAddress(const Socket_Address &addr);
29 
30  bool set_any(int port);
31  bool set_localhost(int port);
32  bool set_broadcast(int port);
33  bool set_host(const std::string &hostname, int port);
34 
35  void clear();
36 
37  int get_port() const;
38  void set_port(int port);
39  std::string get_ip_string() const;
40  bool is_any() const;
41  uint32_t get_ip() const;
42  uint8_t get_ip_component(int n) const;
43 
44  const Socket_Address &get_addr() const;
45 
46  void output(std::ostream &out) const;
47 
48  size_t get_hash() const;
49  bool operator == (const NetAddress &other) const;
50  bool operator != (const NetAddress &other) const;
51 
52 private:
53  Socket_Address _addr;
54 };
55 
56 INLINE std::ostream &operator << (std::ostream &out, const NetAddress &addr) {
57  addr.output(out);
58  return out;
59 }
60 
61 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A simple place to store and manipulate tcp and port address for communication layer.
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition: netAddress.h:25