From 812908e236e83db368dfef49b8badb9a6182e1de Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 28 Oct 2016 04:18:17 +0200 Subject: Fix windows debugger connection problems. Unify network socket creation between platform. Ensure IPV6_V6ONLY flag is not set on sockets (allow IPv4 connection in IPv6 socket, dual-stack). --- drivers/unix/tcp_server_posix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/unix/tcp_server_posix.cpp') diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index 05b739804c..32fda618b2 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -71,8 +71,8 @@ void TCPServerPosix::make_default() { Error TCPServerPosix::listen(uint16_t p_port, IP_Address::AddrType p_type, const List *p_accepted_hosts) { int sockfd; - int family = p_type == IP_Address::TYPE_IPV6 ? AF_INET6 : AF_INET; - sockfd = socket(family, SOCK_STREAM, 0); + sockfd = _socket_create(p_type, SOCK_STREAM, IPPROTO_TCP); + ERR_FAIL_COND_V(sockfd == -1, FAILED); #ifndef NO_FCNTL fcntl(sockfd, F_SETFL, O_NONBLOCK); -- cgit v1.2.3 From eb27e993f0f2fb3de48b7b8aa01c74cc1635a178 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 28 Oct 2016 23:11:53 +0200 Subject: TCP/UDP Listen sockets can now be set to IPv6 only --- drivers/unix/tcp_server_posix.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/unix/tcp_server_posix.cpp') diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index 32fda618b2..7028c1a107 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -74,6 +74,14 @@ Error TCPServerPosix::listen(uint16_t p_port, IP_Address::AddrType p_type, const sockfd = _socket_create(p_type, SOCK_STREAM, IPPROTO_TCP); ERR_FAIL_COND_V(sockfd == -1, FAILED); + + if(p_type == IP_Address::TYPE_IPV6) { + // Use IPv6 only socket + int yes = 1; + if(setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&yes, sizeof(yes)) != 0) { + WARN_PRINT("Unable to unset IPv4 address mapping over IPv6"); + } + } #ifndef NO_FCNTL fcntl(sockfd, F_SETFL, O_NONBLOCK); #else -- cgit v1.2.3