Async Socket Server

Home   »   Async Socket Server

import asyncio, socket

async def handle_client(reader, writer):
    request = None
    while request != 'quit':
        request = (await'utf8')
        response = str(eval(request)) + '\n'
        await writer.drain()

async def run_server():
    server = await asyncio.start_server(handle_client, 'localhost', 15555)
    async with server:
        await server.serve_forever()

Leave a Reply

Your email address will not be published. Required fields are marked *