Remove set_ip_type from network classes (no longer needed)
- TCP:
- `listen` bind to wildcard "*" -> dual stack socket
- `listen` bind to address -> socket from address type
- `connect` -> resolve using best protocol (UNSPEC), socket from address type
- UDP:
- `listen` bind to wildcard "*" -> dual stack socket
- `listen` bind to address -> socket from address type
- `put_packet`/`put_var` -> resolve using TYPE_ANY (UNSPEC), socket from address type
(to change socket type you must first call `close` it)
This commit is contained in:
parent
2fe4ef6699
commit
88a56ba783
18 changed files with 15 additions and 66 deletions
|
|
@ -29,14 +29,9 @@
|
|||
#include "http_client.h"
|
||||
#include "io/stream_peer_ssl.h"
|
||||
|
||||
void HTTPClient::set_ip_type(IP::Type p_type) {
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){
|
||||
|
||||
close();
|
||||
tcp_connection->set_ip_type(ip_type);
|
||||
conn_port=p_port;
|
||||
conn_host=p_host;
|
||||
|
||||
|
|
@ -66,7 +61,7 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,b
|
|||
status=STATUS_CONNECTING;
|
||||
} else {
|
||||
//is hostname
|
||||
resolving=IP::get_singleton()->resolve_hostname_queue_item(conn_host, ip_type);
|
||||
resolving=IP::get_singleton()->resolve_hostname_queue_item(conn_host);
|
||||
status=STATUS_RESOLVING;
|
||||
|
||||
}
|
||||
|
|
@ -639,7 +634,6 @@ Error HTTPClient::_get_http_data(uint8_t* p_buffer, int p_bytes,int &r_received)
|
|||
|
||||
void HTTPClient::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(_MD("set_ip_type","ip_type"),&HTTPClient::set_ip_type);
|
||||
ClassDB::bind_method(_MD("connect_to_host:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect_to_host,DEFVAL(false),DEFVAL(true));
|
||||
ClassDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection);
|
||||
ClassDB::bind_method(_MD("get_connection:StreamPeer"),&HTTPClient::get_connection);
|
||||
|
|
@ -766,7 +760,6 @@ String HTTPClient::query_string_from_dict(const Dictionary& p_dict) {
|
|||
|
||||
HTTPClient::HTTPClient(){
|
||||
|
||||
ip_type = IP::TYPE_ANY;
|
||||
tcp_connection = StreamPeerTCP::create_ref();
|
||||
resolving = IP::RESOLVER_INVALID_ID;
|
||||
status=STATUS_DISCONNECTED;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
IP::Type ip_type;
|
||||
Status status;
|
||||
IP::ResolverID resolving;
|
||||
int conn_port;
|
||||
|
|
@ -165,7 +164,6 @@ private:
|
|||
public:
|
||||
|
||||
|
||||
void set_ip_type(IP::Type p_type);
|
||||
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
|
||||
Error connect_to_host(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ Error PacketPeerUDP::_set_dest_address(const String& p_address, int p_port) {
|
|||
if (p_address.is_valid_ip_address()) {
|
||||
ip=p_address;
|
||||
} else {
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address);
|
||||
if (!ip.is_valid())
|
||||
return ERR_CANT_RESOLVE;
|
||||
}
|
||||
|
|
@ -51,14 +51,8 @@ Error PacketPeerUDP::_set_dest_address(const String& p_address, int p_port) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
void PacketPeerUDP::set_ip_type(IP::Type p_type) {
|
||||
close();
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
void PacketPeerUDP::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(_MD("set_ip_type","ip_type"),&PacketPeerUDP::set_ip_type);
|
||||
ClassDB::bind_method(_MD("listen:Error","port", "bind_address", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL("*"),DEFVAL(65536));
|
||||
ClassDB::bind_method(_MD("close"),&PacketPeerUDP::close);
|
||||
ClassDB::bind_method(_MD("wait:Error"),&PacketPeerUDP::wait);
|
||||
|
|
@ -87,5 +81,5 @@ PacketPeerUDP* PacketPeerUDP::create() {
|
|||
|
||||
PacketPeerUDP::PacketPeerUDP()
|
||||
{
|
||||
ip_type = IP::TYPE_ANY;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@ class PacketPeerUDP : public PacketPeer {
|
|||
|
||||
protected:
|
||||
|
||||
IP::Type ip_type;
|
||||
|
||||
static PacketPeerUDP* (*_create)();
|
||||
static void _bind_methods();
|
||||
|
||||
|
|
@ -49,7 +47,6 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
virtual void set_ip_type(IP::Type p_type);
|
||||
virtual Error listen(int p_port, IP_Address p_bind_address=IP_Address("*"), int p_recv_buffer_size=65536)=0;
|
||||
virtual void close()=0;
|
||||
virtual Error wait()=0;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
|
|||
if (p_address.is_valid_ip_address()) {
|
||||
ip=p_address;
|
||||
} else {
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address);
|
||||
if (!ip.is_valid())
|
||||
return ERR_CANT_RESOLVE;
|
||||
}
|
||||
|
|
@ -45,14 +45,8 @@ Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
void StreamPeerTCP::set_ip_type(IP::Type p_type) {
|
||||
disconnect_from_host();
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
void StreamPeerTCP::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(_MD("set_ip_type","ip_type"),&StreamPeerTCP::set_ip_type);
|
||||
ClassDB::bind_method(_MD("connect_to_host","host","port"),&StreamPeerTCP::_connect);
|
||||
ClassDB::bind_method(_MD("is_connected_to_host"),&StreamPeerTCP::is_connected_to_host);
|
||||
ClassDB::bind_method(_MD("get_status"),&StreamPeerTCP::get_status);
|
||||
|
|
@ -83,7 +77,6 @@ StreamPeerTCP* StreamPeerTCP::create() {
|
|||
|
||||
StreamPeerTCP::StreamPeerTCP() {
|
||||
|
||||
ip_type = IP::TYPE_ANY;
|
||||
}
|
||||
|
||||
StreamPeerTCP::~StreamPeerTCP() {
|
||||
|
|
|
|||
|
|
@ -51,15 +51,12 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
IP::Type ip_type;
|
||||
|
||||
virtual Error _connect(const String& p_address, int p_port);
|
||||
static StreamPeerTCP* (*_create)();
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
||||
virtual void set_ip_type(IP::Type p_type);
|
||||
virtual Error connect_to_host(const IP_Address& p_host, uint16_t p_port)=0;
|
||||
|
||||
//read/write from streampeer
|
||||
|
|
|
|||
|
|
@ -44,14 +44,8 @@ TCP_Server* TCP_Server::create() {
|
|||
return _create();
|
||||
}
|
||||
|
||||
void TCP_Server::set_ip_type(IP::Type p_type) {
|
||||
stop();
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
void TCP_Server::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(_MD("set_ip_type","ip_type"),&TCP_Server::set_ip_type);
|
||||
ClassDB::bind_method(_MD("listen","port","bind_address"),&TCP_Server::listen,DEFVAL("*"));
|
||||
ClassDB::bind_method(_MD("is_connection_available"),&TCP_Server::is_connection_available);
|
||||
ClassDB::bind_method(_MD("take_connection"),&TCP_Server::take_connection);
|
||||
|
|
@ -62,5 +56,5 @@ void TCP_Server::_bind_methods() {
|
|||
|
||||
TCP_Server::TCP_Server()
|
||||
{
|
||||
ip_type = IP::TYPE_ANY;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,12 @@ class TCP_Server : public Reference {
|
|||
GDCLASS( TCP_Server, Reference );
|
||||
protected:
|
||||
|
||||
IP::Type ip_type;
|
||||
|
||||
static TCP_Server* (*_create)();
|
||||
|
||||
//bind helper
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
virtual void set_ip_type(IP::Type p_type);
|
||||
virtual Error listen(uint16_t p_port, const IP_Address p_bind_address=IP_Address("*"))=0;
|
||||
virtual bool is_connection_available() const=0;
|
||||
virtual Ref<StreamPeerTCP> take_connection()=0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue