def __init__(self, host, port, username=None, password=None, *, loop=None):
    self.username = self.password = None
    if (username and password):
        self.username = username.encode('utf-8')
        self.password = password.encode('utf-8')
    self.loop = (loop or asyncio.get_event_loop())
    coro = asyncio.start_server(self.handle_socks, host, port, loop=self.loop)
    self.server = self.loop.run_until_complete(coro)
    (self.host, self.port) = self.server.sockets[0].getsockname()[:2]
def __init__(self, host, port, username=None, password=None, *, loop=None):
    self.username = self.password = None
    if (username and password):
        self.username = username.encode('utf-8')
        self.password = password.encode('utf-8')
    self.loop = (loop or asyncio.get_event_loop())
    coro = asyncio.start_server(self.handle_socks, host, port, loop=self.loop)
    self.server = self.loop.run_until_complete(coro)
    (self.host, self.port) = self.server.sockets[0].getsockname()[:2]