+ }
+
+ {
+ // The system may cap the requested buffer size.
+ // Read back the value and check if it is now as requested.
+ int udp_sndbuf_actual = -1;
+ socklen_t optlen = sizeof(udp_sndbuf_actual);
+
+ if(getsockopt(nfd, SOL_SOCKET, SO_SNDBUF, (void *)&udp_sndbuf_actual, &optlen)) {
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Can't read back UDP SO_SNDBUF: %s", sockstrerror(sockerrno));
+ } else if(optlen != sizeof(udp_sndbuf_actual)) {
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Can't read back UDP SO_SNDBUF: Unexpected returned optlen %jd", (intmax_t) optlen);
+ } else {
+ if(udp_sndbuf_actual != udp_sndbuf) {
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Can't set UDP SO_SNDBUF to %i, the system set it to %i instead", udp_sndbuf, udp_sndbuf_actual);
+ }
+ }
+ }
+
+#if defined(IPV6_V6ONLY)
+
+ if(sa->sa.sa_family == AF_INET6) {
+ setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
+ }