summaryrefslogtreecommitdiff
path: root/listener.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 /listener.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 'listener.c')
-rw-r--r--listener.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/listener.c b/listener.c
index 2835df17..e803bed1 100644
--- a/listener.c
+++ b/listener.c
@@ -245,6 +245,11 @@ evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb,
goto err;
}
+ if (flags & LEV_OPT_BIND_IPV6ONLY) {
+ if (evutil_make_listen_socket_ipv6only(fd) < 0)
+ goto err;
+ }
+
if (sa) {
if (bind(fd, sa, socklen)<0)
goto err;