Skip to content

Commit 2d14d4e

Browse files
pi-anldpgeorge
authored andcommitted
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 <[email protected]>
1 parent 35d07df commit 2d14d4e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extmod/asyncio/stream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ async def start_server(cb, host, port, backlog=5, ssl=None):
180180
import socket
181181

182182
# Create and bind server socket.
183-
host = socket.getaddrinfo(host, port)[0] # TODO this is blocking!
184-
s = socket.socket()
183+
addr_info = socket.getaddrinfo(host, port)[0] # TODO this is blocking!
184+
s = socket.socket(addr_info[0]) # Use address family from getaddrinfo
185185
s.setblocking(False)
186186
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
187-
s.bind(host[-1])
187+
s.bind(addr_info[-1])
188188
s.listen(backlog)
189189

190190
# Create and return server object and task.

0 commit comments

Comments
 (0)