|
|
@@ -187,6 +187,7 @@ using ssize_t = long;
|
|
|
#include <io.h>
|
|
|
#include <winsock2.h>
|
|
|
#include <ws2tcpip.h>
|
|
|
+#include <afunix.h>
|
|
|
|
|
|
#ifndef WSA_FLAG_NO_HANDLE_INHERIT
|
|
|
#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
|
|
|
@@ -3538,7 +3539,6 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
|
|
|
hints.ai_flags = socket_flags;
|
|
|
}
|
|
|
|
|
|
-#ifndef _WIN32
|
|
|
if (hints.ai_family == AF_UNIX) {
|
|
|
const auto addrlen = host.length();
|
|
|
if (addrlen > sizeof(sockaddr_un::sun_path)) { return INVALID_SOCKET; }
|
|
|
@@ -3562,11 +3562,19 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
|
|
|
sizeof(addr) - sizeof(addr.sun_path) + addrlen);
|
|
|
|
|
|
#ifndef SOCK_CLOEXEC
|
|
|
+#ifndef _WIN32
|
|
|
fcntl(sock, F_SETFD, FD_CLOEXEC);
|
|
|
+#endif
|
|
|
#endif
|
|
|
|
|
|
if (socket_options) { socket_options(sock); }
|
|
|
|
|
|
+#ifdef _WIN32
|
|
|
+ // Setting SO_REUSEADDR seems not to work well with AF_UNIX on windows, so avoid
|
|
|
+ // setting default_socket_options.
|
|
|
+ detail::set_socket_opt(sock, SOL_SOCKET, SO_REUSEADDR, 0);
|
|
|
+#endif
|
|
|
+
|
|
|
bool dummy;
|
|
|
if (!bind_or_connect(sock, hints, dummy)) {
|
|
|
close_socket(sock);
|
|
|
@@ -3575,7 +3583,6 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
|
|
|
}
|
|
|
return sock;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
auto service = std::to_string(port);
|
|
|
|