diff options
| -rw-r--r-- | src/platform/posix/posix_resolv_gai.c | 21 | ||||
| -rw-r--r-- | src/platform/windows/win_resolv.c | 21 |
2 files changed, 24 insertions, 18 deletions
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c index f78d0b6b..aea823a0 100644 --- a/src/platform/posix/posix_resolv_gai.c +++ b/src/platform/posix/posix_resolv_gai.c @@ -50,6 +50,7 @@ struct resolv_item { int passive; const char * name; int proto; + int socktype; uint16_t port; nni_aio * aio; nng_sockaddr sa; @@ -138,6 +139,7 @@ resolv_task(resolv_item *item) } hints.ai_protocol = item->proto; hints.ai_family = item->family; + hints.ai_socktype = item->socktype; // We can pass any non-zero service number, but we have to pass // *something*, in case we are using a NULL hostname. @@ -191,7 +193,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; sa_family_t fam; @@ -249,12 +251,13 @@ resolv_ip(const char *host, const char *serv, int passive, int family, // NB: host and serv must remain valid until this is completed. memset(&item->sa, 0, sizeof(item->sa)); - item->name = host; - item->proto = proto; - item->aio = aio; - item->family = fam; - item->passive = passive; - item->port = htons((uint16_t) port); + item->name = host; + item->proto = proto; + item->aio = aio; + item->family = fam; + item->passive = passive; + item->socktype = socktype; + item->port = htons((uint16_t) port); nni_mtx_lock(&resolv_mtx); if (resolv_fini) { @@ -277,14 +280,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 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 |
