summaryrefslogtreecommitdiff
path: root/evutil.c
diff options
context:
space:
mode:
authorMurat Demirten <mdemirten@yh.com.tr>2018-06-04 16:43:34 +0300
committerAzat Khuzhin <a3at.mail@gmail.com>2018-10-26 07:24:29 +0300
commit387d91f9ab95df8ac3d7bb58493310ad4a377dcf (patch)
tree960a1f3e5bfbf51a0c85f92f11dec8b341752b9e /evutil.c
parentb2667b76969c2ea382373f885062b45e82d0ac59 (diff)
downloadlibevent-387d91f9ab95df8ac3d7bb58493310ad4a377dcf.tar.gz
listener: ipv6only socket bind support
According to RFC3493 and most Linux distributions, default value is to work in IPv4-mapped mode. If there is a requirement to bind same port on same ip addresses but different handlers for both IPv4 and IPv6, it is required to set IPV6_V6ONLY socket option to be sure that the code works as expected without affected by bindv6only sysctl setting in system. See an example working with this patch: https://gist.github.com/demirten/023008a63cd966e48b0ebcf9af7fc113 Closes: #640 (cherry-pick)
Diffstat (limited to 'evutil.c')
-rw-r--r--evutil.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/evutil.c b/evutil.c
index d93eff5f..5d385bdc 100644
--- a/evutil.c
+++ b/evutil.c
@@ -386,6 +386,14 @@ evutil_make_listen_socket_reuseable_port(evutil_socket_t sock)
}
int
+evutil_make_listen_socket_ipv6only(evutil_socket_t sock)
+{
+ int one = 1;
+ return setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*) &one,
+ (ev_socklen_t)sizeof(one));
+}
+
+int
evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock)
{
#if defined(EVENT__HAVE_NETINET_TCP_H) && defined(TCP_DEFER_ACCEPT)