def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _create=False):
if family not in (AF_INET, AF_INET6):
raise error(errno.EAFNOSUPPORT, os.strerror(errno.EAFNOSUPPORT))
if type not in (SOCK_STREAM, SOCK_DGRAM):
raise error(errno.EPROTONOSUPPORT, os.strerror(errno.EPROTONOSUPPORT))
if proto:
if ((proto not in (IPPROTO_TCP, IPPROTO_UDP)) or
(proto == IPPROTO_TCP and type != SOCK_STREAM) or
(proto == IPPROTO_UDP and type != SOCK_DGRAM)):
raise error(errno.EPROTONOSUPPORT, os.strerror(errno.EPROTONOSUPPORT))
self.family = family
self.type = type
self.proto = proto
self._created = False
self._fileno = None
self._serialized = False
self.settimeout(getdefaulttimeout())
self._Clear()
if _create:
self._CreateSocket()
评论列表
文章目录