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:
parent
d3108985e0
commit
7de28be764
3 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
5
thirdparty/enet/godot.cpp
vendored
5
thirdparty/enet/godot.cpp
vendored
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue