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.
This commit is contained in:
@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user