summaryrefslogtreecommitdiff
path: root/platform/windows/stream_peer_winsock.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2016-11-30 20:45:19 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2016-12-09 18:24:59 +0100
commit95bdd977686005d3d813eb09aca625384f1774c1 (patch)
tree6d80a57751e2b9af75824e5b0e5bd1a53819b226 /platform/windows/stream_peer_winsock.cpp
parent311f1f165be12ea290799e42f9951011d997ab40 (diff)
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.
Diffstat (limited to 'platform/windows/stream_peer_winsock.cpp')
-rw-r--r--platform/windows/stream_peer_winsock.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp
index 48dd37e9c4..d11724eb8e 100644
--- a/platform/windows/stream_peer_winsock.cpp
+++ b/platform/windows/stream_peer_winsock.cpp
@@ -289,8 +289,9 @@ void StreamPeerWinsock::disconnect() {
peer_port = 0;
};
-void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port) {
+void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP_Address::AddrType p_ip_type) {
+ ip_type = p_ip_type;
sockfd = p_sockfd;
status = STATUS_CONNECTING;
peer_host = p_host;
@@ -301,7 +302,7 @@ Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) {
ERR_FAIL_COND_V( p_host.type == IP_Address::TYPE_NONE, ERR_INVALID_PARAMETER);
- sockfd = _socket_create(p_host.type, SOCK_STREAM, IPPROTO_TCP);
+ sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == INVALID_SOCKET) {
ERR_PRINT("Socket creation failed!");
disconnect();
@@ -367,6 +368,7 @@ StreamPeerWinsock::StreamPeerWinsock() {
sockfd = INVALID_SOCKET;
status = STATUS_NONE;
peer_port = 0;
+ ip_type = IP_Address::TYPE_ANY;
};
StreamPeerWinsock::~StreamPeerWinsock() {