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

Original file line number Diff line number Diff line change
@@ -70,6 +70,13 @@ created. Socket addresses are represented as follows:
70 70 notation like ``'daring.cwi.nl'`` or an IPv4 address like ``'100.50.200.5'``,
71 71 and *port* is an integer.
72 72
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 ``''`` 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 +
73 80 - For :const:`AF_INET6` address family, a four-tuple ``(host, port, flowinfo,
74 81 scopeid)`` is used, where *flowinfo* and *scopeid* represent the ``sin6_flowinfo``
75 82 and ``sin6_scope_id`` members in :const:`struct sockaddr_in6` in C. For
@@ -154,12 +161,6 @@ created. Socket addresses are represented as follows:
154 161
155 162 .. XXX document them!
156 163
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 -``''`` 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 -
163 164 If you use a hostname in the *host* portion of IPv4/v6 socket address, the
164 165 program may show a nondeterministic behavior, as Python uses the first address
165 166 returned from the DNS resolution. The socket address will be resolved