예제 #1
0
파일: start.py 프로젝트: dhou/gogreen
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
예제 #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
예제 #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()