diff options
Diffstat (limited to 'core/io/stream_peer_tcp.cpp')
-rw-r--r-- | core/io/stream_peer_tcp.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index fbb0c69cb7..528f2e8cab 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -30,9 +30,26 @@ 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) { + + IP_Address ip; + if (p_address.is_valid_ip_address()) { + ip=p_address; + } else { + ip=IP::get_singleton()->resolve_hostname(p_address, p_type); + if (ip==IP_Address()) + return ERR_CANT_RESOLVE; + } + + connect(ip,p_port); + return OK; +} + void StreamPeerTCP::_bind_methods() { - ObjectTypeDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::connect); + ObjectTypeDB::bind_method(_MD("connect","host","port","ip_type"),&StreamPeerTCP::_connect,DEFVAL(IP_Address::TYPE_ANY)); 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); |