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

@@ -9,7 +9,7 @@ def main(use_stream=False):
ai = socket.getaddrinfo("google.com", 80)
print("Address infos:", ai)
addr = ai[0][4]
addr = ai[0][-1]
print("Connect address:", addr)
s.connect(addr)