I have a Python app that uses UDP sendto/recvfrom with the socket.MSG_DONTWAIT flag. In Linux and Mac OS X, this works just fine. However, this flag doesn’t exist in the Windows environment.
What is the equivalent flag in Windows? Alternatively, how can I do non-blocking sendto/recvfrom in Windows?
socket.setblocking(False)switches your socket into non-blocking mode on any platform. Call this once on socket creation, and you can remove all theMSG_DONTWAITflags.If you need to switch between blocking and nonblocking I/O (which is usually not the case), call
socket.setblockingevery time you want to switch between those two.