summaryrefslogtreecommitdiff
path: root/drivers/unix/socket_helpers.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-05-12 18:19:24 +0200
committerGitHub <noreply@github.com>2017-05-12 18:19:24 +0200
commit5e318493d1905c83450b30519a149128534a6e10 (patch)
tree4ec0fd4cacde48352ceeffd06c6c81c349c834bb /drivers/unix/socket_helpers.h
parent88d5c943e73cc2f16500c58fb53c71a38f7a0ceb (diff)
parent3b123367a1202e62f31d24e54c8280a97f00aa97 (diff)
Merge pull request #8699 from Faless/ipv6_disabled
Fix Editor/Debugger connection problems.
Diffstat (limited to 'drivers/unix/socket_helpers.h')
-rw-r--r--drivers/unix/socket_helpers.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h
index 8e54afcdba..5fa727a9b9 100644
--- a/drivers/unix/socket_helpers.h
+++ b/drivers/unix/socket_helpers.h
@@ -100,13 +100,21 @@ static size_t _set_listen_sockaddr(struct sockaddr_storage *p_addr, int p_port,
};
};
-static int _socket_create(IP::Type p_type, int type, int protocol) {
+static int _socket_create(IP::Type &p_type, int type, int protocol) {
ERR_FAIL_COND_V(p_type > IP::TYPE_ANY || p_type < IP::TYPE_NONE, ERR_INVALID_PARAMETER);
int family = p_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6;
int sockfd = socket(family, type, protocol);
+ if (sockfd == -1 && p_type == IP::TYPE_ANY) {
+ // Careful here, changing the referenced parameter so the caller knows that we are using an IPv4 socket
+ // in place of a dual stack one, and further calls to _set_sock_addr will work as expected.
+ p_type = IP::TYPE_IPV4;
+ family = AF_INET;
+ sockfd = socket(family, type, protocol);
+ }
+
ERR_FAIL_COND_V(sockfd == -1, -1);
if (family == AF_INET6) {