#!/usr/bin/env python import asyncio from time import sleep PACKET_LEN=128 async def tcp_client(): port = 50001 reader, writer = await asyncio.open_connection( '127.0.0.1', port) with open("loremipsum", "rb") as file_to_send: while message := file_to_send.read(PACKET_LEN): writer.write(message) sleep(1) while message := await reader.read(PACKET_LEN): print(f"Got: {message.decode()}\n\n") asyncio.run(tcp_client())