Skip to content

Instantly share code, notes, and snippets.

Created November 2, 2015 02:44
Show Gist options
  • Save anonymous/0069ea6ae06f14d2ef16 to your computer and use it in GitHub Desktop.
Save anonymous/0069ea6ae06f14d2ef16 to your computer and use it in GitHub Desktop.
Curio client handler
from curio import Kernel, new_task, run_server
async def echo_client(client, addr):
print('Connection from', addr)
while True:
data = await client.recv(1000)
if not data:
break
await client.sendall(data)
await client.close()
print('Connection closed')
if __name__ == '__main__':
kernel = Kernel()
kernel.run(run_server('', 25000, echo_client))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment