首页 > 解决方案 > 如何将多台计算机连接到套接字服务器?

问题描述

我正在使用套接字和线程包制作一个基于 python 的小型聊天应用程序。

应用程序的一部分是服务器,它按预期工作。另一部分是客户端应用程序,它也几乎可以正常工作。客户端输入所需的主机 IP 和主机为服务器打开的端口。我可以将本地客户端连接到我正在运行的服务器(客户端和服务器在同一台计算机上),但是当我尝试使用另一台运行客户端的计算机连接到服务器时,出现 TimeoutError;

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\user\Documents\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "C:\Users\user\Desktop\Client.py", line 46, in connect
    client_socket.connect(ADDR)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

不知道为什么会这样。我认为该端口可能被阻止,但在谷歌搜索后我没有找到任何其他人遇到此特定问题的示例。

我已将服务器端和客户端应用程序上传到 github 存储库;https://github.com/gamer1117/chatapplication

感谢所有帮助。

标签: pythonpython-3.xsocketsserver

解决方案


推荐阅读