Beispiel #1
0
def _lock(server):
    """_lock attempt to bind and listen to server's lockport.
    Returns the listening socket object on success.
    Raises socket.error if the port is already locked.
    """
    s = coro.make_socket(socket.AF_INET, socket.SOCK_STREAM)
    s.set_reuse_addr()
    s.bind((server.get('bind_ip', ''), server['lockport']))
    s.listen(1024)

    return s
Beispiel #2
0
def _lock(server):
    """_lock attempt to bind and listen to server's lockport.
    Returns the listening socket object on success.
    Raises socket.error if the port is already locked.
    """
    s = coro.make_socket(socket.AF_INET, socket.SOCK_STREAM)
    s.set_reuse_addr()
    s.bind((server.get('bind_ip', ''), server['lockport']))
    s.listen(1024)

    return s
Beispiel #3
0
    def run(self):
        self.sock = coro.make_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind(self.addr)
        self.sock.listen(128)

        self.info('Listening to address: %r' % (self.addr,))

        while not self.exit:
            try:
                conn, addr = self.sock.accept()
            except coro.CoroutineSocketWake:
                continue
            except Exception, e:
                self.error('Exception from accept: %r', e)
                break

            eclnt = EchoClient(addr = addr, sock = conn)
            eclnt.start()