每次尝试运行我的程序时,我都尝试连接到本地计算机.我是个笨蛋,所以这可能是某个地方的一个简单错误.
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.
更多推荐
无法建立连接,因为目标机器主动拒绝它
发布评论