mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
tcp::server::ConnectionProvider: Fix dual-stack sockets on Windows (#549).
This commit is contained in:
parent
b8ea2b273d
commit
fc4bf4e983
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user