python - 如何将多台计算机连接到套接字服务器?
问题描述
我正在使用套接字和线程包制作一个基于 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
感谢所有帮助。
解决方案
推荐阅读
- nativescript - 如何在nativescript中上传完成后清除上传通知
- android - 不能删除选中的项目,只删除最后添加的项目
- php - 将颜色覆盖添加到 PNG 的非透明部分
- javascript - 无法通过插件访问 Vue.js 全局函数
- r - 在 Shiny radioButtons 的同一行显示标签和选项
- django - 未提供身份验证凭据 drf
- javascript - 如何从对象数组中显示对象的值?
- c# - 当 Visual Studio 打开时,新的 csproj 会永远重新生成文件
- asp.net - ASP.Net Web.config 客户端端点名称
- tensorflow - 使用 fit_generator() 的分布式张量流