Commit a97a59b1 authored by jan.koester's avatar jan.koester
Browse files

test

parent b45f9728
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -143,6 +143,14 @@ tcp::tcp(const std::string& addr, int port, int maxconnections, int sockopts)
        ::setsockopt(_Socket, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt));
    }
#endif

    // For an IPv6 listening socket, disable IPV6_V6ONLY so the socket accepts
    // both IPv6 and IPv4-mapped connections (dual-stack). This makes binding to
    // "::" serve IPv4 clients too, regardless of the system bindv6only sysctl.
    if (reinterpret_cast<sockaddr*>(&_Addr)->sa_family == AF_INET6) {
        int v6only = 0;
        ::setsockopt(_Socket, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only));
    }
}

void tcp::bind() {
+7 −0
Original line number Diff line number Diff line
@@ -126,6 +126,13 @@ udp::udp(const std::string& addr, int port, int maxconnections, int sockopts)
        ::setsockopt(_Socket, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt));
#endif

    // For an IPv6 socket, disable IPV6_V6ONLY so it accepts both IPv6 and
    // IPv4-mapped traffic (dual-stack), matching the TCP/SSL listener behaviour.
    if (reinterpret_cast<sockaddr*>(&_Addr)->sa_family == AF_INET6) {
        int v6only = 0;
        ::setsockopt(_Socket, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only));
    }

}

udp::udp(const std::string& uxsocket, int maxconnections, int sockopts)