zoukankan      html  css  js  c++  java
  • Python 利用 socket 的 AF_UNIX变量时出现module 'socket' has no attribute 'AF_UNIX' 问题

    从Github上下了一个TensorFlow的工程文件,里面用到了socket的本地连接,使用AF_UNIX

    使用的Win10的系统平台

    发现找不到AF_UNIX的参数

    在socket.py中查看注释,有这一句话:

    """
    socketpair([family[, type[, proto]]]) -> (socket object, socket object)
    Create a pair of socket objects from the sockets returned by the platform
    socketpair() function.
    The arguments are the same as for socket() except the default family is
    AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
    """

    注意到AF_UNIX的存在取决于platform也就是平台

    后继续深入到_socket.py文件查看参数定义,发现:

    AF_APPLETALK = 16
    AF_DECnet = 12
    AF_INET = 2
    AF_INET6 = 23
    AF_IPX = 6
    AF_IRDA = 26
    AF_SNA = 11
    AF_UNSPEC = 0

    果然,AF_UNIX没有被定义

    因此在Win10上使用,应该使用AF_INET

    (另外个人决定UNIX系统上应该能够支持AF_UNIX)

  • 相关阅读:
    java 之 对象与垃圾回收
    Java 之 内部类
    java 接口(interface)
    抽象类
    Java之fianl修饰符
    类的继承
    上传图片
    一般处理程序 给图片添加文字水印
    socket
    初识linq,lambda表达式
  • 原文地址:https://www.cnblogs.com/Nortonary/p/12830092.html
Copyright © 2011-2022 走看看