File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ This module provides access to the BSD socket interface.
1010See corresponding `CPython module <https://docs.python.org/3/library/socket.html >`_ for
1111comparison.
1212
13+ .. admonition :: Difference to CPython
14+ :class: attention
15+
16+ CPython used to have a ``socket.error `` exception which is now deprecated,
17+ and is an alias of OSError. In MicroPython, use OSError directly.
18+
1319Socket address format(s)
1420------------------------
1521
@@ -51,13 +57,18 @@ Functions
5157 s = socket.socket()
5258 s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1])
5359
54- .. only :: port_wipy
55-
56- Exceptions
57- ----------
58-
59- .. data :: socket.error
60- .. data :: socket.timeout
60+ .. admonition :: Difference to CPython
61+ :class: attention
62+
63+ CPython raises a ``socket.gaierror `` exception (OSError subclass) in case
64+ of error in this function. MicroPython doesn't have ``socket.gaierror ``
65+ and raises OSError directly. Note that error numbers of ``getaddrinfo() ``
66+ form a separate namespace and may not match error numbers from
67+ ``uerrno `` module. To distinguish ``getaddrinfo() `` errors, they are
68+ represented by negative numbers, whereas standard system errors are
69+ positive numbers (error numbers are accessible using ``e.args[0] `` property
70+ from an exception object). The use of negative values is a provisional
71+ detail which may change in the future.
6172
6273Constants
6374---------
You can’t perform that action at this time.
0 commit comments