summaryrefslogtreecommitdiff
path: root/core/io/packet_peer_udp.h
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-08-22 19:03:35 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2020-02-16 01:11:30 +0100
commitc4f6ab85b03f6d531ca3dd336d61410f61b6dd76 (patch)
treec7a16d0a5b32ef1f254916774f9feb28bc653042 /core/io/packet_peer_udp.h
parent2811f070840e208cc22485b6ed8dc7f65a631459 (diff)
UDPServer and PacketPeerUDP connect_to_host.
UDP sockets can be "connected" to filter packets from a specific source. In case of a bound socket (e.g. server), a new socket can be created on the same address/port that will receive all packets that are not filtered by a more specific socket (e.g. the previously connect socket). This way, a UDPServer can listen to new packets, and return a new PacketPeerUDP when receiving one, knowing that is a "new client".
Diffstat (limited to 'core/io/packet_peer_udp.h')
-rw-r--r--core/io/packet_peer_udp.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 15b4d00c37..b5a9fc9ec3 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -52,6 +52,7 @@ protected:
IP_Address peer_addr;
int peer_port;
+ bool connected;
bool blocking;
bool broadcast;
Ref<NetSocket> _sock;
@@ -70,6 +71,11 @@ public:
void close();
Error wait();
bool is_listening() const;
+
+ Error connect_socket(Ref<NetSocket> p_sock); // Used by UDPServer
+ Error connect_to_host(const IP_Address &p_host, int p_port);
+ bool is_connected_to_host() const;
+
IP_Address get_packet_address() const;
int get_packet_port() const;
void set_dest_address(const IP_Address &p_address, int p_port);