tcp::server::ConnectionProvider: Fix dual-stack sockets on Windows (#549).

This commit is contained in:
lganzzzo 2022-01-17 02:11:16 +02:00
parent b8ea2b273d
commit fc4bf4e983

View File

@ -184,6 +184,16 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
if (serverHandle != INVALID_SOCKET) {
int no = 0;
if (hints.ai_family == AF_UNSPEC || hints.ai_family == Address::IP_6) {
if (setsockopt(serverHandle, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&no, sizeof( int ) ) != 0 ) {
OATPP_LOGW("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Warning. Failed to set %s for accepting socket: %s", "IPV6_V6ONLY",
strerror(errno));
}
}
if (bind(serverHandle, currResult->ai_addr, (int) currResult->ai_addrlen) != SOCKET_ERROR &&
listen(serverHandle, SOMAXCONN) != SOCKET_ERROR)
{