微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Localhost地址在其上下文中无效?

如何解决Localhost地址在其上下文中无效?

我正在连接到多播服务器(在我自己的计算机上)以接收一些流数据。我声明:

# Change this value to the IP address of the NatNet server.
self.serverIPAddress = "127.0.0.1"

# Change this value to the IP address of your local network interface
self.localIPAddress = "127.0.0.1"

# This should match the multicast address listed in Motive's streaming settings.
self.multicastAddress = "127.0.0.1"
    # Create a data socket to attach to the NatNet stream
    def __createDataSocket( self,port ):
        result = socket.socket( socket.AF_INET,# Internet
                              socket.soCK_DGRAM,socket.IPPROTO_UDP)    # UDP

        result.setsockopt(socket.soL_SOCKET,socket.so_REUSEADDR,1)
        result.setsockopt(socket.IPPROTO_IP,socket.IP_ADD_MEMBERSHIP,socket.inet_aton(self.multicastAddress) + socket.inet_aton(self.localIPAddress))

        result.bind( (self.localIPAddress,port) )

        return result

但要排队

result.setsockopt(socket.IPPROTO_IP,socket.inet_aton(self.multicastAddress) + socket.inet_aton(self.localIPAddress))

我不断收到错误消息:

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

我不明白为什么在使用本地主机(127.0.0.1)时会发生这种情况,有人可以解释吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。