You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
384 B
Python

# asyncio, tcp клиент
import asyncio
async def tcp_echo_client(message, loop):
reader, writer = await asyncio.open_connection("127.0.0.1", 10001, loop=loop)
print("send: %r" % message)
writer.write(message.encode())
writer.close()
loop = asyncio.get_event_loop()
message = "hello World!"
loop.run_until_complete(tcp_echo_client(message, loop))
loop.close()