streams in pythoin

Solutions on MaxInterview for streams in pythoin by the best coders in the world

showing results for - "streams in pythoin"
Eva
28 Jul 2017
1import asyncio
2
3async def tcp_echo_client(message):
4    reader, writer = await asyncio.open_connection(
5        '127.0.0.1', 8888)
6
7    print(f'Send: {message!r}')
8    writer.write(message.encode())
9    await writer.drain()
10
11    data = await reader.read(100)
12    print(f'Received: {data.decode()!r}')
13
14    print('Close the connection')
15    writer.close()
16    await writer.wait_closed()
17
18asyncio.run(tcp_echo_client('Hello World!'))
19