I am trying to run the following python server under windows:
\"\"\"
An echo server that uses select to handle multiple clients at a time.
Entering any line
Look like it does not like sys.stdin
If you change input to this
input = [server]
the exception will go away.
This is from the doc
Note:
File objects on Windows are not acceptable, but sockets are. On Windows, the
underlying select() function is provided by the WinSock library, and does not
handle file descriptors that don’t originate from WinSock.
Of course and the answers given are right... you just have to remove the sys.stdin from the input but still use it in the iteration:
for s in inputready+[sys.stdin]:
I don't know if your code has other problems, but the error you're getting is because of passing input
to select.select()
, the problem is that it contains sys.stdin
which is not a socket. Under Windows, select
only works with sockets.
As a side note, input
is a python function, it's not a good idea to use it as a variable.