summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2025-07-22 19:38:06 +1000
committerDamien George <damien@micropython.org>2025-10-03 22:44:16 +1000
commit2d14d4ef41c88a63f856b4b633478e6a262c85ee (patch)
tree51a786601f95a60540d2f5bd7626dfd461170300
parent35d07df44597237a1aff661bd797c7c78d761ddc (diff)
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 <andrew.leech@planetinnovation.com.au>
-rw-r--r--extmod/asyncio/stream.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/extmod/asyncio/stream.py b/extmod/asyncio/stream.py
index cb0a804b5..10d57ae8a 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.