You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +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.
This commit is contained in:
@@ -38,13 +38,13 @@ String PacketPeerUDP::_get_packet_ip() const {
|
||||
return get_packet_address();
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::_set_send_address(const String& p_address,int p_port,IP_Address::AddrType p_type) {
|
||||
Error PacketPeerUDP::_set_send_address(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;
|
||||
}
|
||||
@@ -55,14 +55,14 @@ Error PacketPeerUDP::_set_send_address(const String& p_address,int p_port,IP_Add
|
||||
|
||||
void PacketPeerUDP::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("listen:Error","port","ip_type", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(IP_Address::TYPE_ANY),DEFVAL(65536));
|
||||
ObjectTypeDB::bind_method(_MD("listen:Error","port", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(65536));
|
||||
ObjectTypeDB::bind_method(_MD("close"),&PacketPeerUDP::close);
|
||||
ObjectTypeDB::bind_method(_MD("wait:Error"),&PacketPeerUDP::wait);
|
||||
ObjectTypeDB::bind_method(_MD("is_listening"),&PacketPeerUDP::is_listening);
|
||||
ObjectTypeDB::bind_method(_MD("get_packet_ip"),&PacketPeerUDP::_get_packet_ip);
|
||||
//ObjectTypeDB::bind_method(_MD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
|
||||
ObjectTypeDB::bind_method(_MD("get_packet_port"),&PacketPeerUDP::get_packet_port);
|
||||
ObjectTypeDB::bind_method(_MD("set_send_address","host","port","ip_type"),&PacketPeerUDP::_set_send_address,DEFVAL(IP_Address::TYPE_ANY));
|
||||
ObjectTypeDB::bind_method(_MD("set_send_address","host","port"),&PacketPeerUDP::_set_send_address);
|
||||
|
||||
|
||||
}
|
||||
@@ -83,4 +83,5 @@ PacketPeerUDP* PacketPeerUDP::create() {
|
||||
|
||||
PacketPeerUDP::PacketPeerUDP()
|
||||
{
|
||||
ip_type = IP_Address::TYPE_ANY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user