Hi, I believe this is because UDP packet can have 0 length payload. I quote some resources here: https://stackoverflow.com/questions/12505892/under-linux-can-recv-ever-return-0-on-udp https://stackoverflow.com/questions/5307031/how-to-detect-receipt-of-a-0-length-udp-datagram
I also found out that sometimes ioctlsocket() call can return error (probably caused by my unstable wifi linux driver), in which case we can also return immediately. I will submit a new version of the patch according to your suggestions. On Fri, 1 Mar 2019 at 04:51, Samuel Thibault <samuel.thiba...@gnu.org> wrote: > > Hello, > > llyzs, le jeu. 28 févr. 2019 19:59:12 +0800, a ecrit: > > Sometimes sorecvfrom() is called from slirp.c because revents == G_IO_IN, > > however inside sorecvfrom() function, ioctlsocket() returns 0 bytes > > available > > and recvfrom could be blocking indefinitely. This adds a non-blocking flag > > to > > recvfrom and checks data availability. > > When ioctlsocket() returns 0 bytes available, we could as well just > immediately return, without even calling recvfrom. We could just move > that ioctlsocket call above the m_get() call, so we can just return > without having to clean up anything. > > This however still looks weird. AFAIK, G_IO_IN means that we can make > one recv call and be sure that it won't block. Do you have an idea why > it wouldn't necessarily be the case? > > Samuel