Skip to content

Instantly share code, notes, and snippets.

@George3d6
Last active September 16, 2018 23:15
Show Gist options
  • Save George3d6/6c5b74adb3e51c7d06c05d0d5de2a5a1 to your computer and use it in GitHub Desktop.
Save George3d6/6c5b74adb3e51c7d06c05d0d5de2a5a1 to your computer and use it in GitHub Desktop.
import asyncio
async def send(addr, port, message):
con = asyncio.open_connection(addr, port)
reader, writer = await con
writer.write(message)
buffer_size = 254
data = await reader.read(buffer_size)
print('Got back the messages: {}'.format(data))
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(
send('8.8.8.8', 1234, 46)
,send('1.1.1.1', 4321, 3)
))
loop.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment