From 2d14d4ef41c88a63f856b4b633478e6a262c85ee Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Tue, 22 Jul 2025 19:38:06 +1000 Subject: [PATCH] extmod/asyncio: Add IPv6 support to start_server(). Ensures that the underlying socket is opened with the correct protocol as parsed by `getaddrinfo()`. Signed-off-by: Andrew Leech --- extmod/asyncio/stream.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extmod/asyncio/stream.py b/extmod/asyncio/stream.py index cb0a804b5e..10d57ae8a1 100644 --- a/extmod/asyncio/stream.py +++ b/extmod/asyncio/stream.py @@ -180,11 +180,11 @@ async def start_server(cb, host, port, backlog=5, ssl=None): import socket # Create and bind server socket. - host = socket.getaddrinfo(host, port)[0] # TODO this is blocking! - s = socket.socket() + addr_info = socket.getaddrinfo(host, port)[0] # TODO this is blocking! + s = socket.socket(addr_info[0]) # Use address family from getaddrinfo s.setblocking(False) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - s.bind(host[-1]) + s.bind(addr_info[-1]) s.listen(backlog) # Create and return server object and task.