def connected(self): if not self.serving: return try: for sock in self._sockets: try: io, _ = sock.accept() except socket.error, exc: if exc.errno in error.block: continue raise AcceptError( 'could not accept a new connection (%s)' % errstr(exc)) try: if sock.family == socket.AF_INET: local_ip = io.getpeername()[0] # local_ip,local_port remote_ip = io.getsockname()[ 0] # remote_ip,remote_port elif sock.family == socket.AF_INET6: local_ip = io.getpeername()[ 0] # local_ip,local_port,local_flow,local_scope remote_ip = io.getsockname( )[0] # remote_ip,remote_port,remote_flow,remote_scope else: raise AcceptError('unexpected address family (%d)' % sock.family) fam = self._family_AFI_map[sock.family] yield Incoming(fam, remote_ip, local_ip, io) except socket.error, exc: raise AcceptError('could not setup a new connection (%s)' % errstr(exc))
def connected(self): if not self.serving: return try: for sock, (host, _) in self._sockets.items(): try: io, _ = sock.accept() if sock.family == socket.AF_INET: local_ip, local_port = io.getpeername() remote_ip, remote_port = io.getsockname() elif sock.family == socket.AF_INET6: local_ip, local_port, local_flow, local_scope = io.getpeername( ) remote_ip, remote_port, remote_flow, remote_scope = io.getsockname( ) else: raise AcceptError('unexpected address family (%d)' % sock.family) fam = self._family_AFI_map[sock.family] yield Incoming(fam, remote_ip, local_ip, io) break except socket.error, exc: if exc.errno in error.block: continue raise AcceptError( 'could not accept a new connection (%s)' % errstr(exc)) except NetworkError, exc: self.logger.network(str(exc), 'critical') raise exc
def _connected (self): try: for sock,io in list(self._accepted.items()): del self._accepted[sock] if sock.family == socket.AF_INET: local_ip = io.getpeername()[0] # local_ip,local_port remote_ip = io.getsockname()[0] # remote_ip,remote_port elif sock.family == socket.AF_INET6: local_ip = io.getpeername()[0] # local_ip,local_port,local_flow,local_scope remote_ip = io.getsockname()[0] # remote_ip,remote_port,remote_flow,remote_scope else: raise AcceptError('unexpected address family (%d)' % sock.family) fam = self._family_AFI_map[sock.family] yield Incoming(fam,remote_ip,local_ip,io) except NetworkError as exc: self.logger.critical(str(exc),'network')
def connected (self): if not self.serving: return try: for sock,(host,_) in self._sockets.items(): try: io, _ = sock.accept() local_ip,local_port = io.getpeername() remote_ip,remote_port = io.getsockname() yield Incoming(AFI.ipv4,remote_ip,local_ip,io) break except socket.error, e: if e.errno in error.block: continue raise AcceptError('could not accept a new connection (%s)' % errstr(e)) except NetworkError,e: self.logger.network(str(e),'critical') raise e