参数必须是int或具有fileno()方法-选择

时间:2019-08-06 12:59:02

标签: python select

我必须为一个学校项目在python中建立一个聊天程序,而我在这个错误上停留了pf几天,现在我仍然没有找到问题所在以及如何解决该问题

我尝试在互联网上查找并更改代码并询问朋友,但我无法解决它 在此先感谢所有帮助者

有问题的部分

def main():
    server_socket = open_server_connection
    while True:
        time.sleep(0.5)
        # updating the sockets lists
        rlist, wlist, xlist = select.select([server_socket] + open_client_sockets, open_client_sockets, [])
        for current_socket in rlist:
           #checking whether the socket is able to send messages
            if current_socket is server_socket:
                #checking if its a new connection
                (new_socket, address) = server_socket.accept()
                open_client_sockets.append(new_socket)
                unnamed_clients.append(open_client_sockets[-1])
                print "new client connected. \n"

错误:

Traceback (most recent call last):
  File "C:/Users/USER/Pictures/noya diy/summer cyber/summer_hw_noya_server.py", line 339, in <module>
    main()
  File "C:/Users/USER/Pictures/noya diy/summer cyber/summer_hw_noya_server.py", line 246, in main
    rlist, wlist, xlist = select.select([server_socket] + open_client_sockets, open_client_sockets, [])
TypeError: argument must be an int, or have a fileno() method

0 个答案:

没有答案