简体   繁体   中英

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. There is a server.py file and a client.py file. I took example code straight out of the Python doc for sockets to see if that would work, and it does not. 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. My OS is Windows 10 and I'm using IDLE. I've looked at my Firewall and set a permission for pythonw.exe to be allowed through, but that has not helped. 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. 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. A socket won't connect to itself!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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