SHARE
TWEET

Untitled

a guest Jun 25th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async def lookup(server, port, query, sema):
  2.     async with sema as sema:
  3.         try:
  4.             reader, writer = await asyncio.open_connection(server, port)
  5.         except:
  6.             return {}
  7.         writer.write(query.encode("ISO-8859-1"))
  8.         await writer.drain()
  9.         data = b""
  10.         while True:
  11.             d = await reader.read(4096)
  12.             if not d:
  13.                 break
  14.             data += d
  15.         writer.close()
  16.         data = data.decode("ISO-8859-1")
  17.         return data
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top