From: Lennart Poettering Date: Thu, 6 Apr 2006 23:28:15 +0000 (+0000) Subject: * set IPV6_V6ONLY for IPv6 sockets, to avoid warning when both ipv6 and the ipv4... X-Git-Tag: 1.0_branch~3875 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73035a82a7abde862b171daf7b4cb77a50c8e14b;p=profile%2Fivi%2Fpulseaudio.git * set IPV6_V6ONLY for IPv6 sockets, to avoid warning when both ipv6 and the ipv4 sockets try to bind to the same port * enable SO_REUSEADDR only on platforms that support it git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@643 fefdeb5f-60dc-0310-8127-8f9354f1896f --- diff --git a/src/polypcore/socket-server.c b/src/polypcore/socket-server.c index baa31e6..b27816d 100644 --- a/src/polypcore/socket-server.c +++ b/src/polypcore/socket-server.c @@ -231,8 +231,10 @@ pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address pa_fd_set_cloexec(fd, 1); - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on)) < 0) +#ifdef SO_REUSEADDR + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) pa_log(__FILE__": setsockopt(): %s", strerror(errno)); +#endif pa_socket_tcp_low_delay(fd); @@ -280,8 +282,15 @@ pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t ad pa_fd_set_cloexec(fd, 1); - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on)) < 0) - pa_log(__FILE__": setsockopt(): %s", strerror(errno)); +#ifdef IPV6_V6ONLY + if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) + pa_log(__FILE__": setsockopt(IPPROTO_IPV6, IPV6_V6ONLY): %s", strerror(errno)); +#endif + +#ifdef SO_REUSEADDR + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) + pa_log(__FILE__": setsockopt(SOL_SOCKET, SO_REUSEADDR, 1): %s", strerror(errno)); +#endif pa_socket_tcp_low_delay(fd);