简体   繁体   English

Windows 10 不允许 Python server.py 与 client.py 连接

[英]Windows 10 not allowing Python server.py to connect with client.py

I'm working a tutorial in Python 3.8 that involves sockets and networking.我正在使用 Python 3.8 编写一个涉及套接字和网络的教程。 There is a server.py file and a client.py file.有一个 server.py 文件和一个 client.py 文件。 I took example code straight out of the Python doc for sockets to see if that would work, and it does not.我直接从 Python doc for sockets 中提取了示例代码,看看这是否可行,但它不可行。 The server starts and creates a socket and listens for the connection, but I get WinError 10061, the one where the target machine refuses the connection.服务器启动并创建一个套接字并侦听连接,但我得到 WinError 10061,目标机器拒绝连接。 My OS is Windows 10 and I'm using IDLE.我的操作系统是 Windows 10,我使用的是 IDLE。 I've looked at my Firewall and set a permission for pythonw.exe to be allowed through, but that has not helped.我查看了我的防火墙并设置了允许 pythonw.exe 通过的权限,但这并没有帮助。 Anybody have any fixes for me to try?有人有任何修复方法让我尝试吗? I can't really proceed until I can get the client and server connected.在连接客户端和服务器之前,我无法真正继续。

I think I know what I've been doing wrong.我想我知道我做错了什么。 I have been running both server and client files in the same console.我一直在同一个控制台中运行服务器和客户端文件。 I think I have to open two consoles and run one file in each so they can communicate.我想我必须打开两个控制台并在每个控制台中运行一个文件,以便它们可以进行通信。 (Doh!) I'm at work so I can't test it right now. (Doh!)我在工作,所以我现在不能测试它。 Just in case anyone else has been befuddled by this .以防万一其他人被这弄糊涂了。

Yes, I did not realize that each file had to run in its own instance of IDLE, but that makes perfect sense now.是的,我没有意识到每个文件都必须在它自己的 IDLE 实例中运行,但现在这很有意义。 A socket won't connect to itself!套接字不会连接到自身!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM