examples/network/: Use getaddrinfo() result in easy way.

Instead of extracting 4th element, extact last. Much easier to remember!
This commit is contained in:
Paul Sokolovsky
2016-05-03 00:45:37 +03:00
parent 3944d3511f
commit c2d885501f
4 changed files with 4 additions and 4 deletions

View File

@@ -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)