def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() self._sock.setblocking(0) self._read_event = core.event(core.EV_READ, self.fileno(), _wait_helper) self._write_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper) # regarding the following, see issue #31 # (http://code.google.com/p/gevent/issues/detail?id=31#c19) if is_windows: self._rw_event = core.event(core.EV_READ | core.EV_WRITE, self.fileno(), _wait_helper) else: self._rw_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper)
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() self._sock.setblocking(0)
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): self._sock = _socket.socket(family, type, proto, fileno) self._io_refs = 0 self._closed = False self._sock.setblocking(0) self.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) self.timeout = _socket.getdefaulttimeout()
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() self._io_refs = 0 # for Python 3 self._sock.setblocking(0) self._io = IOHandler(self._sock.fileno()) self._closed = False
def __init_common(self): _socket.socket.setblocking(self._sock, False) fileno = _socket.socket.fileno(self._sock) self.hub = get_hub() io_class = self.hub.loop.io self._read_event = io_class(fileno, 1) self._write_event = io_class(fileno, 2) self.timeout = _socket.getdefaulttimeout()
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() self._sock.setblocking(0) self._read_event = core.event(core.EV_READ, self.fileno(), _wait_helper) self._write_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper) self._rw_event = core.event(core.EV_READ|core.EV_WRITE, self.fileno(), _wait_helper)
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() self._sock.setblocking(0) fileno = self._sock.fileno() self.hub = get_hub() io = self.hub.loop.io self._read_event = io(fileno, 1) self._write_event = io(fileno, 2)
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): _socket.socket.__init__(self, family, type, proto, fileno) self._io_refs = 0 self._closed = False _socket.socket.setblocking(self, False) fileno = _socket.socket.fileno(self) self.hub = get_hub() io_class = self.hub.loop.io self._read_event = io_class(fileno, 1) self._write_event = io_class(fileno, 2) self.timeout = _socket.getdefaulttimeout()
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): if _sock is None: self._sock = _realsocket(family, type, proto) self.timeout = _socket.getdefaulttimeout() else: if hasattr(_sock, '_sock'): self._sock = _sock._sock self.timeout = getattr(_sock, 'timeout', False) if self.timeout is False: self.timeout = _socket.getdefaulttimeout() else: self._sock = _sock self.timeout = _socket.getdefaulttimeout() self._sock.setblocking(0) self._read_event = core.event(core.EV_READ, self.fileno(), _wait_helper) self._write_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper) self._rw_event = core.event(core.EV_READ | core.EV_WRITE, self.fileno(), _wait_helper)
def accept(self): fd, addr = super(JsonSocket, self)._accept() jsock = JsonSocket(super(JsonSocket, self).family, super(JsonSocket, self).type, super(JsonSocket, self).proto, fileno=fd) # Issue #7995: if no default timeout is set and the listening # socket had a (non-zero) timeout, force the new socket in blocking # mode to override platform-specific socket flags inheritance. if _socket.getdefaulttimeout() is None and super(JsonSocket, self).gettimeout(): jsock.setblocking(True) return jsock, addr
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): # Take the same approach as socket2: wrap a real socket object, # don't subclass it. This lets code that needs the raw _sock (not tied to the hub) # get it. This shows up in tests like test__example_udp_server. self._sock = _wrefsocket(family, type, proto, fileno) self._io_refs = 0 self._closed = False _socket.socket.setblocking(self._sock, False) fileno = _socket.socket.fileno(self._sock) self.hub = get_hub() io_class = self.hub.loop.io self._read_event = io_class(fileno, 1) self._write_event = io_class(fileno, 2) self.timeout = _socket.getdefaulttimeout()
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): # Take the same approach as socket2: wrap a real socket object, # don't subclass it. This lets code that needs the raw _sock (not tied to the hub) # get it. This shows up in tests like test__example_udp_server. self._sock = self._gevent_sock_class(family, type, proto, fileno) self._io_refs = 0 self._closed = False _socket.socket.setblocking(self._sock, False) fileno = _socket.socket.fileno(self._sock) self.hub = get_hub() io_class = self.hub.loop.io self._read_event = io_class(fileno, 1) self._write_event = io_class(fileno, 2) self.timeout = _socket.getdefaulttimeout()
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): super().__init__(family, type, proto, fileno) self._io_refs = 0 self._closed = False super().setblocking(False) self.timeout = _socket.getdefaulttimeout()