If no packet is available, we generally get an EAGAIN exception and return None.
If there is a packet, we skip the exception and proceed to the code that
handles the datagram content (not shown).
- Code: Select all
buf, senderAdr = self.sock.recvfrom(2000)
except error as e :
if e.errno == errno.EAGAIN : return None
# treat anything else as fatal error
This code was written for Unix/Linux and works fine on my Mac or a Linux machine.
I would like to know how to do the same thing on a windows machine. I've tried
substituting errno.EWOULDBLOCK, since it appears that Windows uses this
error code. But it also appears that there may be more hoops to jump through
to get this to work on Windows.