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.
This commit is contained in:
Fabio Alessandrelli
2017-03-08 17:14:01 +01:00
parent 38d457170a
commit 5f681d0b0f
7 changed files with 73 additions and 15 deletions

View File

@ -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;