ENet wrapper properly detect disconnect on poll

Now PacketPeerUDP.get_available_packet_count() return -1 if the socket
is in error state.
This commit is contained in:
Fabio Alessandrelli 2018-08-31 03:22:41 +02:00
parent d3108985e0
commit 7de28be764
3 changed files with 5 additions and 4 deletions

View file

@ -61,7 +61,7 @@ int PacketPeerUDPPosix::get_available_packet_count() const {
Error err = const_cast<PacketPeerUDPPosix *>(this)->_poll(false);
if (err != OK)
return 0;
return -1;
return queue_count;
}

View file

@ -42,7 +42,7 @@ int PacketPeerUDPWinsock::get_available_packet_count() const {
Error err = const_cast<PacketPeerUDPWinsock *>(this)->_poll(false);
if (err != OK)
return 0;
return -1;
return queue_count;
}

View file

@ -168,8 +168,9 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf
PacketPeerUDP *sock = (PacketPeerUDP *)socket;
if (sock->get_available_packet_count() == 0) {
return 0;
int pc = sock->get_available_packet_count();
if (pc < 1) {
return pc;
}
const uint8_t *buffer;