def __init__(self): self.s = _socket() self.s.bind((HOST, PORT)) self.s.listen(5) self.clients = [] self.clientKeys = {} self.clientCiphers = {} self.lastPing = time() self.haveNotPong = set() self.secure = Secure() self.matches = [] Thread(target=self.accept, daemon=True).start() Thread(target=self.listen, daemon=True).start()
def _sd_notify(self, status): """ Notify systemd. Args: status (bytes): Notification message. """ try: with _socket(_AF_UNIX, _SOCK_DGRAM) as notify_socket: notify_socket.connect(self._sd_notify_address) notify_socket.sendall(status) except OSError: # Send nothing if socket disabled pass
def run(self): """ Contains the thread main loop - opens and binds the server socket and waits for client connections NOTE: use x.start() to run the thread. x.run() is used internally. """ debug_output('opening socket on %r' % (self.address,)) self._sock = sock = _socket(self.family, self.sock_type, self.sock_prot) sock.bind(self.address) sock.listen(1) debug_output('starting socket loop') while True: conn, addr = sock.accept() conn.send("##"+i2s(self.resolution[0], 2)+i2s(self.resolution[1], 2)) with self._clients_lock: self._clients.append((conn, addr))
def run(self): """ Contains the thread main loop - opens and binds the server socket and waits for client connections NOTE: use x.start() to run the thread. x.run() is used internally. """ debug_output('opening socket on %r' % (self.address, )) self._sock = sock = _socket(self.family, self.sock_type, self.sock_prot) sock.bind(self.address) sock.listen(1) debug_output('starting socket loop') while True: conn, addr = sock.accept() conn.send("##" + i2s(self.resolution[0], 2) + i2s(self.resolution[1], 2)) with self._clients_lock: self._clients.append((conn, addr))
def __init__(self, *args, **kwargs): self._ss = _socket(*args, **kwargs) self.records = [] self.recording = False self.replaying = False
def socket(family=AF_INET, type=SOCK_STREAM, proto=0): return closing(_socket(family, type, proto))
def new_socket(address): socket = _socket(AF_INET, SOCK_STREAM) socket.connect(address) socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) socket.setblocking(0) return socket
def socket(family = AF_INET, type = SOCK_STREAM, proto = 0): return closing(_socket(family, type, proto))