首页 > 解决方案 > Python绑定公共IP以在没有相同网络的情况下连接

问题描述

我想绑定公共 ip 以连接没有相同网络的套接字。我该怎么做?

我试过了:

    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # Set the socket
    server.bind(("public_ip", 12345))

我得到一个错误:

OSError: [WinError 10049] The requested address is not valid in its context

为什么它不工作?我是否在正确的路径上接收来自不在同一网络上的客户端的消息?

标签: pythonsocketsnetworkingserveripv6

解决方案


推荐阅读