OpenDDS  Snapshot(2023/04/28-20:55)
NetworkResource.inl
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
9 
10 #include <ace/CDR_Stream.h>
11 #include <ace/OS_NS_netdb.h>
12 
14 
17  : reserved_(0)
18 {
19  DBG_ENTRY_LVL("NetworkResource","NetworkResource",6);
20 }
21 
24  : reserved_(0)
25 {
26  DBG_ENTRY_LVL("NetworkResource","NetworkResource",6);
27 
28  ACE_TCHAR addr_s[MAXHOSTNAMELEN + 1];
29  addr.addr_to_string(addr_s, sizeof (addr_s), 1 /* ipaddr_format */);
30 
31  this->addr_ = ACE_TEXT_ALWAYS_CHAR(addr_s);
32 }
33 
36  : reserved_(0)
37 {
38  DBG_ENTRY_LVL("NetworkResource","NetworkResource",6);
39 
40  addr_ = addr;
41 }
42 
45 {
46 }
47 
50 {
51  DBG_ENTRY_LVL("NetworkResource","to_addr",6);
52  addr = choose_single_coherent_address(addr_.c_str(), true /*prefer_loopback*/);
53  VDBG_LVL((LM_DEBUG, "(%P|%t) NetworkResource::to_addr() - Resolving address for %C to be %C\n", addr_.c_str(), addr.get_host_addr()), 2);
54 }
55 
58 {
59  ACE_DEBUG((LM_DEBUG, "(%P|%t) NetworkResource addr: %C reserved: %d\n", addr_.c_str(), reserved_));
60 }
61 
const char * get_host_addr(char *addr, int addr_size) const
#define ACE_DEBUG(X)
std::string String
String addr_
The address in string format. e.g. ip:port, hostname:port.
#define ACE_TEXT_ALWAYS_CHAR(STRING)
LM_DEBUG
char ACE_TCHAR
#define MAXHOSTNAMELEN
ACE_INET_Addr choose_single_coherent_address(const ACE_INET_Addr &address, bool prefer_loopback)
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
#define VDBG_LVL(DBG_ARGS, LEVEL)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
virtual int addr_to_string(ACE_TCHAR buffer[], size_t size, int ipaddr_format=1) const
#define ACE_INLINE
void to_addr(ACE_INET_Addr &addr) const