summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2017-03-08 17:14:01 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2017-03-24 02:30:11 +0100
commit5f681d0b0f28cd39bc033c0cdf8eb3cb3a4acbe6 (patch)
tree5c94a8cc2537076223598b4007943e436cf750b4 /core
parent38d457170a15fd9eb902cecc8c5dc401646cd0b8 (diff)
Allow non blocking UDP put_packet in C++.
- Add blocking mode option to PacketPeerUDP. - put_packet returns ERR_UNAVAILABLE when operation would block. - ENet module uses non-blocking UDP.
Diffstat (limited to 'core')
-rw-r--r--core/io/packet_peer_udp.cpp7
-rw-r--r--core/io/packet_peer_udp.h4
2 files changed, 11 insertions, 0 deletions
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 46accf420a..3bc116f1b6 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -31,6 +31,11 @@
PacketPeerUDP *(*PacketPeerUDP::_create)() = NULL;
+void PacketPeerUDP::set_blocking_mode(bool p_enable) {
+
+ blocking = p_enable;
+}
+
String PacketPeerUDP::_get_packet_ip() const {
return get_packet_address();
@@ -78,4 +83,6 @@ PacketPeerUDP *PacketPeerUDP::create() {
}
PacketPeerUDP::PacketPeerUDP() {
+
+ blocking = true;
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index c316faad4b..c486f443fb 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -36,6 +36,8 @@ class PacketPeerUDP : public PacketPeer {
GDCLASS(PacketPeerUDP, PacketPeer);
protected:
+ bool blocking;
+
static PacketPeerUDP *(*_create)();
static void _bind_methods();
@@ -44,6 +46,8 @@ protected:
Error _set_dest_address(const String &p_address, int p_port);
public:
+ void set_blocking_mode(bool p_enable);
+
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;