29 addrinfo* pResultList = NULL;
33 std::string strHostName(pszHostName);
39 hints.ai_family = family;
42 hints.ai_flags = AI_NUMERICHOST;
46 hints.ai_socktype = SOCK_STREAM;
48 ret = getaddrinfo(strHostName.c_str(), NULL, &hints, &pResultList);
58 if (pResultList != NULL)
60 ::freeaddrinfo(pResultList);
73 if (family == AF_INET)
75 sockaddr_in addr4 = {};
76 ChkIf(0 == ::inet_pton(family, pszIP, &addr4.sin_addr),
E_FAIL);
77 addr4.sin_family = family;
82 sockaddr_in6 addr6 = {};
83 ChkIf(0 == ::inet_pton(family, pszIP, &addr6.sin6_addr),
E_FAIL);
84 addr6.sin6_family = family;
HRESULT ResolveHostName(const char *pszHostName, int family, bool fNumericOnly, CSocketAddress *pAddr)
#define ERRNO_TO_HRESULT(err)
#define ChkIf(expr, hrerror)
HRESULT NumericIPToAddress(int family, const char *pszIP, CSocketAddress *pAddr)
void Trim(std::string &str)