bpo-33921: Clarify how to bind to all interfaces using socket (GH-7877) · python/cpython@30f295b

Original file line numberDiff line numberDiff line change

@@ -70,6 +70,13 @@ created. Socket addresses are represented as follows:

7070

notation like ``'daring.cwi.nl'`` or an IPv4 address like ``'100.50.200.5'``,

7171

and *port* is an integer.

7272
73+

- For IPv4 addresses, two special forms are accepted instead of a host

74+

address: ``''`` represents :const:`INADDR_ANY`, which is used to bind to all

75+

interfaces, and the string ``'<broadcast>'`` represents

76+

:const:`INADDR_BROADCAST`. This behavior is not compatible with IPv6,

77+

therefore, you may want to avoid these if you intend to support IPv6 with your

78+

Python programs.

79+
7380

- For :const:`AF_INET6` address family, a four-tuple ``(host, port, flowinfo,

7481

scopeid)`` is used, where *flowinfo* and *scopeid* represent the ``sin6_flowinfo``

7582

and ``sin6_scope_id`` members in :const:`struct sockaddr_in6` in C. For

@@ -154,12 +161,6 @@ created. Socket addresses are represented as follows:

154161
155162

.. XXX document them!

156163
157-

For IPv4 addresses, two special forms are accepted instead of a host address:

158-

the empty string represents :const:`INADDR_ANY`, and the string

159-

``'<broadcast>'`` represents :const:`INADDR_BROADCAST`. This behavior is not

160-

compatible with IPv6, therefore, you may want to avoid these if you intend

161-

to support IPv6 with your Python programs.

162-
163164

If you use a hostname in the *host* portion of IPv4/v6 socket address, the

164165

program may show a nondeterministic behavior, as Python uses the first address

165166

returned from the DNS resolution. The socket address will be resolved