On Sat, Sep 12, 2009 at 15:57:30 +0200, Bas Wijnen wrote: > + fds = g_malloc (max_num_fds * sizeof (*fds)); > + for (aip = ai; aip; aip = aip->ai_next) { > + fds[*num_fds] = socket(aip->ai_family, SOCK_STREAM, 0); > + if (fds[*num_fds] < 0) { > continue; > } > - yes = 1; > > /* setsockopt() before bind(); otherwise it has no effect! -- > egnor */ > + yes = 1; > if (setsockopt > - (fd, SOL_SOCKET, SO_REUSEADDR, &yes, > + (fds[*num_fds], SOL_SOCKET, SO_REUSEADDR, &yes, > sizeof(yes)) < 0) { > - net_closesocket(fd); > + g_warning(_("" > + "Not using socket because setting REUSEADDR > failed: %s\n"), > + net_errormsg()); > + net_closesocket(fds[*num_fds]); > continue; > }
you may want to add here something like: if ((aip->ai_family == AF_INET6) && (setsockopt(fds[*num_fds], IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof(yes)) < 0)) { net_closesocket(fds[*num_fds]); continue; } to avoid on ipv6 socket trying to get ipv4 connections (if you're looping over all addresses anyway, you'll have AF_INET sockets for your v4 addresses) > - if (bind(fd, aip->ai_addr, aip->ai_addrlen) < 0) { > - net_closesocket(fd); > + if (bind(fds[*num_fds], aip->ai_addr, aip->ai_addrlen) < 0) { > + g_warning(_("" > + "Not using socket because bind failed: %s\n"), > + net_errormsg()); > + net_closesocket(fds[*num_fds]); > continue; > } > Cheers, Julien -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org