RevenantX / LiteNetLib

Lite reliable UDP library for Mono and .NET
https://revenantx.github.io/LiteNetLib/index.html
MIT License
3.06k stars 495 forks source link

Fix Linux Specific Softlock on empty datagrams #534

Closed ced777ric closed 10 months ago

ced777ric commented 10 months ago

Due to a difference in behaviour in DotNet on linux the Socket::Available property behaves differently.

On linux it will return 0 when an empty datagram is received, which results in the receivethread softlocking. To resolve this we can use the selectReadList alongside Socket::Available.

Additionally, on linux the native socket will return a size 0 for empty packets aswel. So we shouldn't kill the receive loop when the size is 0, as that would mean an empty packet can kill the receive thread.