无法建立连接,因为目标机器主动拒绝它

编程入门 行业动态 更新时间:2024-10-28 05:25:40
本文介绍了无法建立连接,因为目标机器主动拒绝它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每次尝试运行我的程序时,我都尝试连接到本地计算机.我是个笨蛋,所以这可能是某个地方的一个简单错误.

I've tried to connect to my local machine every time I try and run my program. I am a nub, so it's probably a simple mistake somewhere.

def connect(self): self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.conn.connect((self.host,self.port))

那是导致错误的代码.定义了主机和端口.为什么它给我这个错误报告?

That is the code causing the error. The host and port are defined. Why is it giving me this error report?

[Errno 10061] 无法建立连接,因为目标机器主动拒绝

[Errno 10061] No connection could be made because the target machine actively refused it

推荐答案

这是因为您还没有打开您尝试连接的端口,那里没有任何东西在侦听.如果您尝试连接到 Web 或 ftp 服务器,请先启动它.如果您尝试连接到另一个端口,则还需要编写一个服务器应用程序.

It's because you haven't opened the port you are trying to connect to, nothing is listening there. If you're trying to connect to a web or ftp server, start it first. If you're trying to connect to another port, you need to write a server application too.

更多推荐

无法建立连接,因为目标机器主动拒绝它

本文发布于:2023-10-23 20:05:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主动   机器   目标

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!