summaryrefslogtreecommitdiff
path: root/docs/library/usocket.rst
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-02-27 22:03:52 -0500
committerGitHub <noreply@github.com>2018-02-27 22:03:52 -0500
commit568c04e6afa8016062f685b2198c0209f62827f4 (patch)
treed07b76119f715add462983b335797adf64b61249 /docs/library/usocket.rst
parent6a2379fd0bfe10017d8abc5c36ef1d470c0d9b27 (diff)
parentea633117d01d94e8d56ed94344e4b3e46b4eef03 (diff)
Merge pull request #650 from tannewt/merge_2x3.0.0-alpha.2
Merge in commits from 2.x branch.
Diffstat (limited to 'docs/library/usocket.rst')
-rw-r--r--docs/library/usocket.rst31
1 files changed, 14 insertions, 17 deletions
diff --git a/docs/library/usocket.rst b/docs/library/usocket.rst
index fab05b652..b07ba4413 100644
--- a/docs/library/usocket.rst
+++ b/docs/library/usocket.rst
@@ -2,10 +2,12 @@
:mod:`usocket` -- socket module
*******************************
+.. include:: ../templates/unsupported_in_circuitpython.inc
+
.. module:: usocket
:synopsis: socket module
-|see_cpython_module| :mod:`python:socket`.
+|see_cpython_module| :mod:`cpython:socket`.
This module provides access to the BSD socket interface.
@@ -36,11 +38,7 @@ power) and portable way to work with addresses.
However, ``socket`` module (note the difference with native MicroPython
``usocket`` module described here) provides CPython-compatible way to specify
-addresses using tuples, as described below. Note that depending on a
-`MicroPython port`, ``socket`` module can be builtin or need to be
-installed from `micropython-lib` (as in the case of `MicroPython Unix port`),
-and some ports still accept only numeric addresses in the tuple format,
-and require to use `getaddrinfo` function to resolve domain names.
+addresses using tuples, as described below.
Summing up:
@@ -60,8 +58,7 @@ Tuple address format for ``socket`` module:
and *port* is an integer port number in the range 1-65535. *flowinfo*
must be 0. *scopeid* is the interface scope identifier for link-local
addresses. Note the domain names are not accepted as *ipv6_address*,
- they should be resolved first using `usocket.getaddrinfo()`. Availability
- of IPv6 support depends on a `MicroPython port`.
+ they should be resolved first using `usocket.getaddrinfo()`.
Functions
---------
@@ -81,8 +78,8 @@ Functions
.. function:: getaddrinfo(host, port)
- Translate the host/port argument into a sequence of 5-tuples that contain all the
- necessary arguments for creating a socket connected to that service. The list of
+ Translate the host/port argument into a sequence of 5-tuples that contain all the
+ necessary arguments for creating a socket connected to that service. The list of
5-tuples has following structure::
(family, type, proto, canonname, sockaddr)
@@ -99,7 +96,7 @@ Functions
of error in this function. MicroPython doesn't have ``socket.gaierror``
and raises OSError directly. Note that error numbers of `getaddrinfo()`
form a separate namespace and may not match error numbers from
- `uerrno` module. To distinguish `getaddrinfo()` errors, they are
+ :py:mod:`uerrno` module. To distinguish `getaddrinfo()` errors, they are
represented by negative numbers, whereas standard system errors are
positive numbers (error numbers are accessible using ``e.args[0]`` property
from an exception object). The use of negative values is a provisional
@@ -127,7 +124,7 @@ Constants
.. data:: AF_INET
AF_INET6
- Address family types. Availability depends on a particular `MicroPython port`.
+ Address family types. Availability depends on a particular ``MicroPython port``.
.. data:: SOCK_STREAM
SOCK_DGRAM
@@ -137,7 +134,7 @@ Constants
.. data:: IPPROTO_UDP
IPPROTO_TCP
- IP protocol numbers. Availability depends on a particular `MicroPython port`.
+ IP protocol numbers. Availability depends on a particular ``MicroPython port``.
Note that you don't need to specify these in a call to `usocket.socket()`,
because `SOCK_STREAM` socket type automatically selects `IPPROTO_TCP`, and
`SOCK_DGRAM` - `IPPROTO_UDP`. Thus, the only real use of these constants
@@ -146,12 +143,12 @@ Constants
.. data:: usocket.SOL_*
Socket option levels (an argument to `setsockopt()`). The exact
- inventory depends on a `MicroPython port`.
+ inventory depends on a ``MicroPython port``.
.. data:: usocket.SO_*
Socket options (an argument to `setsockopt()`). The exact
- inventory depends on a `MicroPython port`.
+ inventory depends on a ``MicroPython port``.
Constants specific to WiPy:
@@ -171,7 +168,7 @@ Methods
on the socket object will fail. The remote end will receive EOF indication if
supported by protocol.
- Sockets are automatically closed when they are garbage-collected, but it is recommended
+ Sockets are automatically closed when they are garbage-collected, but it is recommended
to `close()` them explicitly as soon you finished working with them.
.. method:: socket.bind(address)
@@ -245,7 +242,7 @@ Methods
completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
is put in blocking mode.
- Not every `MicroPython port` supports this method. A more portable and
+ Not every ``MicroPython port`` supports this method. A more portable and
generic solution is to use `uselect.poll` object. This allows to wait on
multiple objects at the same time (and not just on sockets, but on generic
stream objects which support polling). Example::