You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
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.
(cherry picked from commit 95bdd97768)
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user