Skip to content

Instantly share code, notes, and snippets.

@ankitml
Created February 14, 2019 14:48
Show Gist options
  • Save ankitml/b623169af8a363324eaa4d4640e64fc9 to your computer and use it in GitHub Desktop.
Save ankitml/b623169af8a363324eaa4d4640e64fc9 to your computer and use it in GitHub Desktop.
client for ipc communication through tcp port
import asyncio
async def client(message):
message = message + '\n' + message + '\n'
reader, writer = await asyncio.open_connection(
'127.0.0.1', 8888)
print(f'Send: {message!r}')
writer.write(message.encode())
while True:
if reader.at_eof():
break
data = await reader.readline()
print(f'Received: {data.decode()!r}')
print('Close the connection')
writer.close()
asyncio.run(client('Hello World!'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment