Skip to content

Commit 95dfb9c

Browse files
johnthagentiran
authored andcommitted
bpo-33921: Clarify how to bind to all interfaces using socket (GH-7877)
Clarify how to bind to all interfaces using socket
1 parent 937fb55 commit 95dfb9c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Doc/library/socket.rst

Lines changed: 7 additions & 6 deletions
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
@@ -171,12 +178,6 @@ created. Socket addresses are represented as follows:
171178

172179
.. XXX document them!
173180
174-
For IPv4 addresses, two special forms are accepted instead of a host address:
175-
the empty string represents :const:`INADDR_ANY`, and the string
176-
``'<broadcast>'`` represents :const:`INADDR_BROADCAST`. This behavior is not
177-
compatible with IPv6, therefore, you may want to avoid these if you intend
178-
to support IPv6 with your Python programs.
179-
180181
If you use a hostname in the *host* portion of IPv4/v6 socket address, the
181182
program may show a nondeterministic behavior, as Python uses the first address
182183
returned from the DNS resolution. The socket address will be resolved

0 commit comments

Comments
 (0)