summaryrefslogtreecommitdiffstats
path: root/drivers/unix/tcp_server_posix.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-01-02 15:51:45 +0100
committerGitHub <noreply@github.com>2017-01-02 15:51:45 +0100
commit0b2771bd6561152cdb0e650538a572a242068f01 (patch)
treeb44c1ab2d50f14521cb7d9cafcee37b551871c66 /drivers/unix/tcp_server_posix.cpp
parent6428ebd91faa757aff419e3f6d1ccc63b699dd11 (diff)
parentd194e1c48e5d161f0310ee17e63f1951e2c50de6 (diff)
downloadredot-engine-0b2771bd6561152cdb0e650538a572a242068f01.tar.gz
Merge pull request #7271 from Faless/ipv6_cleanup
Fixes and improvementes for IPv6 implementation.
Diffstat (limited to 'drivers/unix/tcp_server_posix.cpp')
-rw-r--r--drivers/unix/tcp_server_posix.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp
index ef971c0c70..0178f08b8c 100644
--- a/drivers/unix/tcp_server_posix.cpp
+++ b/drivers/unix/tcp_server_posix.cpp
@@ -68,20 +68,13 @@ void TCPServerPosix::make_default() {
TCP_Server::_create = TCPServerPosix::_create;
};
-Error TCPServerPosix::listen(uint16_t p_port, IP_Address::AddrType p_type, const List<String> *p_accepted_hosts) {
+Error TCPServerPosix::listen(uint16_t p_port,const List<String> *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) {
- // 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
@@ -95,7 +88,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 +157,7 @@ Ref<StreamPeerTCP> 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 +176,7 @@ void TCPServerPosix::stop() {
TCPServerPosix::TCPServerPosix() {
listen_sockfd = -1;
+ ip_type = IP::TYPE_ANY;
};
TCPServerPosix::~TCPServerPosix() {