mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
examples/network/: Use getaddrinfo() result in easy way.
Instead of extracting 4th element, extact last. Much easier to remember!
This commit is contained in:
@@ -16,7 +16,7 @@ def main(use_stream=False):
|
||||
# Binding to all interfaces - server will be accessible to other hosts!
|
||||
ai = socket.getaddrinfo("0.0.0.0", 8080)
|
||||
print("Bind address info:", ai)
|
||||
addr = ai[0][4]
|
||||
addr = ai[0][-1]
|
||||
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind(addr)
|
||||
|
||||
Reference in New Issue
Block a user