Created
November 2, 2015 02:44
-
-
Save anonymous/0069ea6ae06f14d2ef16 to your computer and use it in GitHub Desktop.
Curio client handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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