Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5375

MicroPython • Re: uasyncio error

$
0
0
AttributeError: 'Server' object has no attribute 'serve_forever'
I note you have two 'start_server' functions defined, presumably the original for Port 80, and what you added for Port 5000 -

Code:

async def start_server():    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    server.bind(('0.0.0.0', 80))    server.listen(5)    print('Server listening on 0.0.0.0 port 80')    while True:        client, addr = await server.accept()        await asyncio.create_task(handle_client(client, addr))

Code:

async def start_server():    server = await asyncio.start_server(handle_client, '0.0.0.0', 5000)    print('Server running on port 5000')    async with server:        await server.serve_forever()
I am not familiar with 'asyncio' but I would guess it's a good idea to model your addition on what the original is. Perhaps use the original and just change the port number from 80 to 5000 ?

Statistics: Posted by hippy — Mon Jul 15, 2024 9:59 am



Viewing all articles
Browse latest Browse all 5375

Trending Articles