diff options
author | Hans Zandbelt <Hans.Zandbelt@telin.nl> | 2005-07-21 21:10:23 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-07-21 21:10:23 +0000 |
commit | 276358c1c40311a068c17639fe4c0135710b7688 (patch) | |
tree | ef4064a8bc751cc808e8d83e214c16c79e3801fd /libavformat/udp.c | |
parent | 8baa661498e5c7846088721a2e686d9a521da0db (diff) | |
download | ffmpeg-276358c1c40311a068c17639fe4c0135710b7688.tar.gz |
udp ipv6 localhost resolving patch by ("Hans Zandbelt": Hans Zandbelt, telin nl)
Originally committed as revision 4463 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r-- | libavformat/udp.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c index 50aa14bfaf..3f3a9f760b 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -160,24 +160,26 @@ int udp_ipv6_set_local(URLContext *h) { 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"); |