diff options
| author | Fabio Alessandrelli | 2016-10-28 04:18:17 +0200 |
|---|---|---|
| committer | Fabio Alessandrelli | 2016-12-11 18:12:45 +0100 |
| commit | 70a6791150729d14ca54558f778a84af2252d3c8 (patch) | |
| tree | 42ad69322950240eb2e0d70db80ea271597801aa /drivers/unix/socket_helpers.h | |
| parent | 6e0de0cce81ee8972dc997279c2c830f7b412b4d (diff) | |
| download | godot-70a6791150729d14ca54558f778a84af2252d3c8.tar.gz godot-70a6791150729d14ca54558f778a84af2252d3c8.tar.zst godot-70a6791150729d14ca54558f778a84af2252d3c8.zip | |
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).
(cherry picked from commit 812908e236e83db368dfef49b8badb9a6182e1de)
Diffstat (limited to 'drivers/unix/socket_helpers.h')
| -rw-r--r-- | drivers/unix/socket_helpers.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h index 4ee40e3d3..b432a028b 100644 --- a/drivers/unix/socket_helpers.h +++ b/drivers/unix/socket_helpers.h @@ -45,6 +45,27 @@ static size_t _set_listen_sockaddr(struct sockaddr_storage* p_addr, int p_port, }; }; +static int _socket_create(IP_Address::AddrType p_type, int type, int protocol) { + + ERR_FAIL_COND_V(p_type > IP_Address::TYPE_ANY || p_type < IP_Address::TYPE_NONE, ERR_INVALID_PARAMETER); + + int family = p_type == IP_Address::TYPE_IPV4 ? AF_INET : AF_INET6; + int sockfd = socket(family, type, protocol); + + ERR_FAIL_COND_V( sockfd == -1, -1 ); + + if(family == AF_INET6) { + // Ensure IPv4 over IPv6 is enabled + int v6_only = 0; + if(setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&v6_only, sizeof(v6_only)) != 0) { + WARN_PRINT("Unable to set IPv4 address mapping over IPv6"); + } + } + + return sockfd; +} + + static void _set_ip_addr_port(IP_Address& r_ip, int& r_port, struct sockaddr_storage* p_addr) { if (p_addr->ss_family == AF_INET) { |
