extmod/asyncio/stream.py: Add ipv6 support to start_server(). #17311
+234
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I'm starting to use ipv6 more with micropython devices as their discoverability can actually be much better on a local network, without worrying about needing to manually configure (ipv4) ip addresses.
To that end, this PR adds support to start_server() to automatically use the parsed protocol, ie setting
socket.AF_INET
orsocket.AF_INET6
on the socket as parsed bygetaddrinfo()
When adding unit tests for this change, I found the multi-test runner was missing support for ipv6 ip address detection, so that's been added as well (in a separate commit)
The ip address detection in multi-test runner has also been updated to use the newer / preferred
network.ipconfig("addr4")
style interface by default, falling back to ipconfig if needed.Testing
Unit tests are included which check ipv6 support in both
net_hosted
style test andmult_net
tests.Without the change to
extmod/asyncio/stream.py
the tests fails withOSError: 97
Trade-offs and Alternatives