Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cNetDNS Class Reference

#include <cNetDNS.h>

Public Member Functions

 cNetDNS () noexcept
 
 cNetDNS (const char *pszHost, NET_PORT_t wPortDefault=k_NET_PORT_INVALID)
 
bool SetAddrList (const hostent *pHostEnt)
 
HRESULT SetByName (const char *pszHost, NET_PORT_t wPortDefault=k_NET_PORT_INVALID)
 
const cNetAddressGetByFamily (sa_family_t nFamily=AF_UNSPEC) const
 
const cNetAddress *_cdecl GetByFamilyV (sa_family_t nFamily,...) const
 
 UNITTEST_FRIEND (cNetDNS)
 

Static Public Member Functions

static cStringA GRAYCALL GetHostName (const cNetAddress &rAddr, bool bAliases=false)
 
static cStringA GRAYCALL GetHostName2 (const cNetAddress &rAddr, bool bAliases=false, OUT cStringA *psPort=nullptr, bool bWait=true)
 
static bool GRAYCALL IsValidHostEntry (const hostent *pHostEnt)
 
static const hostent *GRAYCALL FindHostEntryByName (const char *pszHostName)
 

Public Attributes

cNetAddressArray m_AddrList
 List of cNetAddress resolved from hostname (String) on DNS. More...
 

Detailed Description

DNS helper functions. similar to 'nslookup' command . A hostname (from DNS server) can return a list of host addresses. e.g. 1 for ip6 and 1 for ip4. etc. Allow reverse lookup of address to name. May be in local cache or a blocking call to a DNS server. Assume k_NET_HOSTNAME_MAX

Constructor & Destructor Documentation

◆ cNetDNS() [1/2]

GrayLib::cNetDNS::cNetDNS ( )
inlinenoexcept

◆ cNetDNS() [2/2]

GrayLib::cNetDNS::cNetDNS ( const char *  pszHost,
NET_PORT_t  wPortDefault = k_NET_PORT_INVALID 
)
inline

blocking access to DNS services. May be cached or not.

Member Function Documentation

◆ FindHostEntryByName()

const hostent *GRAYCALL GrayLib::cNetDNS::FindHostEntryByName ( const char *  pszHostName)
static

lookup hostent by name. This is an old call. it has security problems. use getaddrinfo. Legacy IPv4 version The return value is only good until the next call to this function on this thread. danger. call cNetSocket::GetLastError. on failure.

Note
This is a blocking (synchronous) call?

◆ GetByFamily()

const cNetAddress * GrayLib::cNetDNS::GetByFamily ( sa_family_t  nFamily = AF_UNSPEC) const

Find an cNetAddress entry by preferred sa_family_t.

◆ GetByFamilyV()

const cNetAddress *_cdecl GrayLib::cNetDNS::GetByFamilyV ( sa_family_t  nFamily,
  ... 
) const

Find an cNetAddress entry by preferred sa_family_t.

◆ GetHostName()

cStringA GRAYCALL GrayLib::cNetDNS::GetHostName ( const cNetAddress rAddr,
bool  bAliases = false 
)
static

Try to reverse lookup a name for this cNetAddress. multiple host addressed in "HOSTENT" This is a blocking (synchronous) call! Legacy Equiv of GetAddrInfo() getnameinfo(). Use GetHostName2() or GetNameInfoW

◆ GetHostName2()

cStringA GRAYCALL GrayLib::cNetDNS::GetHostName2 ( const cNetAddress rAddr,
bool  bAliases = false,
OUT cStringA psPort = nullptr,
bool  bWait = true 
)
static

Try to reverse lookup a name for this address. Modern version of GetHostName() ::getnameinfo() NOT supported in WIN2K (or UNDER_CE ?) USE_WINSOCK2_ADDR

  • bWait = can be a blocking call to get name (else just numeric).

◆ IsValidHostEntry()

bool GRAYCALL GrayLib::cNetDNS::IsValidHostEntry ( const hostent *  pHostEnt)
static

valid HOSTENT ? has at least 1 entry.

◆ SetAddrList()

bool GrayLib::cNetDNS::SetAddrList ( const hostent *  pHostEnt)

Legacy IPv4 version

◆ SetByName()

HRESULT GrayLib::cNetDNS::SetByName ( const char *  pszHost,
NET_PORT_t  wPortDefault = k_NET_PORT_INVALID 
)

Get the IP list from the address name we looked up. NOT set port.

  • wPortDefault = set it to this port if it is not set explicitly. 0 = don't set to anything. pszHost = nullptr = localhost all interfaces.
    Returns
    # of addresses returned.
    Note
    This is a blocking call.

◆ UNITTEST_FRIEND()

GrayLib::cNetDNS::UNITTEST_FRIEND ( cNetDNS  )

Member Data Documentation

◆ m_AddrList

cNetAddressArray GrayLib::cNetDNS::m_AddrList

List of cNetAddress resolved from hostname (String) on DNS.


The documentation for this class was generated from the following files: