mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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>
This commit is contained in:
committed by
Damien George
parent
35d07df445
commit
2d14d4ef41
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user