# HG changeset patch # User michael # Date 1121980223 0 # Node ID c8d4a65729c523d86db32bfbc600a30e5baa42c0 # Parent 779b1e87b865dc170a14900abf4b9a709cdc7a3b udp ipv6 localhost resolving patch by ("Hans Zandbelt": Hans Zandbelt, telin nl) diff -r 779b1e87b865 -r c8d4a65729c5 udp.c --- a/udp.c Tue Jul 19 15:32:43 2005 +0000 +++ b/udp.c Thu Jul 21 21:10:23 2005 +0000 @@ -160,24 +160,26 @@ socklen_t addrlen; char sbuf[NI_MAXSERV]; char hbuf[NI_MAXHOST]; - struct addrinfo *res0 = NULL; - int family; + struct addrinfo *res0 = NULL, *res = NULL; if (s->local_port != 0) { res0 = udp_ipv6_resolve_host(0, s->local_port, SOCK_DGRAM, AF_UNSPEC, AI_PASSIVE); if (res0 == 0) goto fail; - family = res0->ai_family; + for (res = res0; res; res=res->ai_next) { + udp_fd = socket(res->ai_family, SOCK_DGRAM, 0); + if (udp_fd > 0) break; + perror("socket"); + } } else { - family = s->dest_addr.ss_family; + udp_fd = socket(s->dest_addr.ss_family, SOCK_DGRAM, 0); + if (udp_fd < 0) + perror("socket"); } - - udp_fd = socket(family, SOCK_DGRAM, 0); - if (udp_fd < 0) { - perror("socket"); + + if (udp_fd < 0) goto fail; - } - + if (s->local_port != 0) { if (bind(udp_fd, res0->ai_addr, res0->ai_addrlen) < 0) { perror("bind");