I am testing UDP stamping using the code here . It works on Linux, but reports an error on Windows. Here is the code snippet where the error occurs:
while True:
rfds, _, _ = select([0, sockfd], [], [])
if 0 in rfds:
data = sys.stdin.readline()
if not data:
break
sockfd.sendto(data, target)
elif sockfd in rfds:
data, addr = sockfd.recvfrom(1024)
sys.stdout.write(data)
And the error message:
Traceback (most recent call last):
File "udp_punch_client.py", line 64, in <module>
main()
File "udp_punch_client.py", line 50, in main
rfds, _, _ = select([0, sockfd], [], [])
select.error: (10038, '')
I know this error has something to do with the implementation selecton Windows, and all this is quoted:
Note File objects on Windows are not acceptable, but sockets. On Windows, the main select () function is provided by the WinSock library and does not process file descriptors that do not arise from WinSock.
I had two questions:
- What does mean
0in [0, sockfd]? Is this some commonly used method? - If it
selectworks only with socketWindows, how to make the code compatible with Windows?
Thank.