Skip to content
Snippets Groups Projects
Commit ae845f13 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

docs: Use getaddrinfo() result in easy way.

Instead of extracting 4th element, extact last. Much easier to remember!
parent c2d88550
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ Functions ...@@ -49,7 +49,7 @@ Functions
The following example shows how to connect to a given url:: The following example shows how to connect to a given url::
s = socket.socket() s = socket.socket()
s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][4]) s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1])
.. only:: port_wipy .. only:: port_wipy
......
...@@ -21,7 +21,7 @@ Functions ...@@ -21,7 +21,7 @@ Functions
import ssl import ssl
s = socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC) s = socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
ss = ssl.wrap_socket(s) ss = ssl.wrap_socket(s)
ss.connect(socket.getaddrinfo('www.google.com', 443)[0][4]) ss.connect(socket.getaddrinfo('www.google.com', 443)[0][-1])
Certificates must be used in order to validate the other side of the connection, and also to Certificates must be used in order to validate the other side of the connection, and also to
authenticate ourselves with the other end. Such certificates must be stored as files using the authenticate ourselves with the other end. Such certificates must be stored as files using the
...@@ -44,7 +44,7 @@ Functions ...@@ -44,7 +44,7 @@ Functions
import ssl import ssl
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
ss = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/flash/cert/ca.pem') ss = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/flash/cert/ca.pem')
ss.connect(socket.getaddrinfo('cloud.blynk.cc', 8441)[0][4]) ss.connect(socket.getaddrinfo('cloud.blynk.cc', 8441)[0][-1])
SSL sockets inherit all methods and from the standard sockets, see the :mod:`usocket` module. SSL sockets inherit all methods and from the standard sockets, see the :mod:`usocket` module.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment