No connection could be made because the target mac

2019-01-12 08:35发布

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] No connection could be made because the target machine actively refused it

1条回答
做个烂人
2楼-- · 2019-01-12 08:58

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.

查看更多
登录 后发表回答