【问题标题】:Calling inet_pton through Cython通过 Cython 调用 inet_pton
【发布时间】:2011-05-04 17:35:16
【问题描述】:

我想在 Cython 中调用 inet_pton 来获取 IPv6 地址。基本上我想做相当于下面的C代码:

char str[16];
inet_pton(AF_INET6, "12:212::122", &str);

我尝试了以下方法:

cdef char buff[16]
inet_pton(AF_INET6, address, &buff):

但这会报错:“Taking address of non-lvalue”。

正确的做法是什么?最后我需要将 IPv6 地址字符串转换为 python long。

【问题讨论】:

  • 请注意,您应该使用 getnameinfogetaddrinfo 作为 inet_ptoninet_ntop 不支持 IPv6 区域。

标签: python posix ipv6 cython


【解决方案1】:

使用buff&buff[0] 代替&buff

【讨论】:

    猜你喜欢
    • 2014-04-30
    • 2015-06-04
    • 2019-03-06
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    • 1970-01-01
    • 2017-10-01
    相关资源
    最近更新 更多