Last active
September 16, 2018 23:15
-
-
Save George3d6/6c5b74adb3e51c7d06c05d0d5de2a5a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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