1
0
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:
Fabio Alessandrelli
2016-11-30 20:45:19 +01:00
parent c030e602e5
commit a46a643f90
18 changed files with 68 additions and 51 deletions

View File

@@ -32,13 +32,13 @@ StreamPeerTCP* (*StreamPeerTCP::_create)()=NULL;
VARIANT_ENUM_CAST(IP_Address::AddrType);
Error StreamPeerTCP::_connect(const String& p_address,int p_port,IP_Address::AddrType p_type) {
Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
IP_Address ip;
if (p_address.is_valid_ip_address()) {
ip=p_address;
} else {
ip=IP::get_singleton()->resolve_hostname(p_address, p_type);
ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
if (ip==IP_Address())
return ERR_CANT_RESOLVE;
}
@@ -49,7 +49,7 @@ Error StreamPeerTCP::_connect(const String& p_address,int p_port,IP_Address::Add
void StreamPeerTCP::_bind_methods() {
ObjectTypeDB::bind_method(_MD("connect","host","port","ip_type"),&StreamPeerTCP::_connect,DEFVAL(IP_Address::TYPE_ANY));
ObjectTypeDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::_connect);
ObjectTypeDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected);
ObjectTypeDB::bind_method(_MD("get_status"),&StreamPeerTCP::get_status);
ObjectTypeDB::bind_method(_MD("get_connected_host"),&StreamPeerTCP::get_connected_host);
@@ -79,6 +79,7 @@ StreamPeerTCP* StreamPeerTCP::create() {
StreamPeerTCP::StreamPeerTCP() {
ip_type = IP_Address::TYPE_ANY;
}
StreamPeerTCP::~StreamPeerTCP() {