From 9b9526e4a643d36d9c66f2254f00df7298e5562f Mon Sep 17 00:00:00 2001 From: Mike Bush Date: Tue, 24 Jul 2018 09:02:13 -0400 Subject: Modified code to explicitly set hints.ai_socktype passed to getaddrinfo(). On QNX, specifying a numeric servname while leaving ai_socktype unspecified would result in EAI_SERVICE. --- src/platform/windows/win_resolv.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/platform/windows') diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c index 916f54b1..cc876d04 100644 --- a/src/platform/windows/win_resolv.c +++ b/src/platform/windows/win_resolv.c @@ -38,6 +38,7 @@ struct resolv_item { int passive; const char * name; int proto; + int socktype; uint16_t port; nni_aio * aio; nng_sockaddr sa; @@ -115,6 +116,7 @@ resolv_task(resolv_item *item) } hints.ai_protocol = item->proto; hints.ai_family = item->family; + hints.ai_socktype = item->socktype; if ((rv = getaddrinfo(item->name, "80", &hints, &results)) != 0) { rv = resolv_errno(rv); @@ -165,7 +167,7 @@ done: static void resolv_ip(const char *host, const char *serv, int passive, int family, - int proto, nni_aio *aio) + int proto, int socktype, nni_aio *aio) { resolv_item *item; int fam; @@ -222,12 +224,13 @@ resolv_ip(const char *host, const char *serv, int passive, int family, return; } memset(&item->sa, 0, sizeof(item->sa)); - item->passive = passive; - item->name = host; - item->proto = proto; - item->aio = aio; - item->family = fam; - item->port = htons((uint16_t) port); + item->passive = passive; + item->name = host; + item->proto = proto; + item->aio = aio; + item->family = fam; + item->socktype = socktype; + item->port = htons((uint16_t) port); nni_mtx_lock(&resolv_mtx); if (resolv_fini) { @@ -250,14 +253,14 @@ void nni_tcp_resolv( const char *host, const char *serv, int family, int passive, nni_aio *aio) { - resolv_ip(host, serv, passive, family, IPPROTO_TCP, aio); + resolv_ip(host, serv, passive, family, IPPROTO_TCP, SOCK_STREAM, aio); } void nni_udp_resolv( const char *host, const char *serv, int family, int passive, nni_aio *aio) { - resolv_ip(host, serv, passive, family, IPPROTO_UDP, aio); + resolv_ip(host, serv, passive, family, IPPROTO_UDP, SOCK_DGRAM, aio); } void -- cgit v1.2.3-70-g09d2