Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

sockets - Python Error: io.UnsupportedOperation: fileno

I am using a server and the client programs from this link: http://www.bogotobogo.com/python/python_network_programming_tcp_server_client_chat_server_chat_client_select.php

When I run the client I encounter the following error:

Traceback (most recent call last):
  File "client.py", line 26, in client
    read_sockets, write_sockets, error_sockets =     select.select(socket_list , [], [])
io.UnsupportedOperation: fileno

I am using Python 3, but I have changed all lines using print from Python 2 to 3.

Here is the code:

while 1:
        socket_list = [sys.stdin, s]
        # Get the list sockets which are readable
        read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

While the fileno() method works on normal IO objects (sys.stdout, sys.stderr, sys.stdin and socket.socket), the IDLE Python IDE changes your IO objects which breaks this.

So... if you get this error, run the command from straight up Python instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...