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 From 95bdd977686005d3d813eb09aca625384f1774c1 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 30 Nov 2016 20:45:19 +0100 Subject: Use an instance variable for ip_type in raw sockets PacketPeerUDP/StreamPeerTCP/TCP_Server now uses an instance variable to store the selected ip_type (IPv4/IPv6/ANY, where ANY = dual stack). All calls to resolve addresses, sending/receving data, connecting/listening will use that socket type. --- drivers/unix/tcp_server_posix.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 7028c1a107..e6f3614cb5 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -68,14 +68,14 @@ void TCPServerPosix::make_default() { TCP_Server::_create = TCPServerPosix::_create; }; -Error TCPServerPosix::listen(uint16_t p_port, IP_Address::AddrType p_type, const List *p_accepted_hosts) { +Error TCPServerPosix::listen(uint16_t p_port,const List *p_accepted_hosts) { int sockfd; - sockfd = _socket_create(p_type, SOCK_STREAM, IPPROTO_TCP); + sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP); ERR_FAIL_COND_V(sockfd == -1, FAILED); - if(p_type == IP_Address::TYPE_IPV6) { + if(ip_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) { @@ -95,7 +95,7 @@ Error TCPServerPosix::listen(uint16_t p_port, IP_Address::AddrType p_type, const } struct sockaddr_storage addr; - size_t addr_size = _set_listen_sockaddr(&addr, p_port, p_type, p_accepted_hosts); + size_t addr_size = _set_listen_sockaddr(&addr, p_port, ip_type, p_accepted_hosts); // automatically fill with my IP TODO: use p_accepted_hosts @@ -164,7 +164,7 @@ Ref TCPServerPosix::take_connection() { int port; _set_ip_addr_port(ip, port, &their_addr); - conn->set_socket(fd, ip, port); + conn->set_socket(fd, ip, port, ip_type); return conn; }; @@ -183,6 +183,7 @@ void TCPServerPosix::stop() { TCPServerPosix::TCPServerPosix() { listen_sockfd = -1; + ip_type = IP_Address::TYPE_ANY; }; TCPServerPosix::~TCPServerPosix() { -- cgit v1.2.3 From 4d90a4fcd5fcdca42df47062f94a1fa4e5635a94 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 1 Dec 2016 05:05:44 +0100 Subject: Move V6ONLY flag selection inside helpers --- drivers/unix/tcp_server_posix.cpp | 7 ------- 1 file changed, 7 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 e6f3614cb5..bf3b7369eb 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -75,13 +75,6 @@ Error TCPServerPosix::listen(uint16_t p_port,const List *p_accepted_host ERR_FAIL_COND_V(sockfd == -1, FAILED); - if(ip_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 From c18c5013f837ea7d4de2f022d36f84e0abce6439 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 1 Dec 2016 06:34:05 +0100 Subject: Migrate int.IP_TYPE_ constants to IP.TYPE_ --- drivers/unix/tcp_server_posix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 bf3b7369eb..dd00e0bf7e 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -176,7 +176,7 @@ void TCPServerPosix::stop() { TCPServerPosix::TCPServerPosix() { listen_sockfd = -1; - ip_type = IP_Address::TYPE_ANY; + ip_type = IP::TYPE_ANY; }; TCPServerPosix::~TCPServerPosix() { -- cgit v1.2.3 From c7bc44d5ad9aae4902280012f7654e2318cd910e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 1 Jan 2017 22:01:57 +0100 Subject: Welcome in 2017, dear changelog reader! That year should bring the long-awaited OpenGL ES 3.0 compatible renderer with state-of-the-art rendering techniques tuned to work as low as middle end handheld devices - without compromising with the possibilities given for higher end desktop games of course. Great times ahead for the Godot community and the gamers that will play our games! --- drivers/unix/tcp_server_posix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 7028c1a107..ef971c0c70 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3