Skip to content

Commit cf23eed

Browse files
committed
Docs: don't rely on implicit 'above' directions
1 parent 0055140 commit cf23eed

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

Doc/library/socket.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ is implicit on send operations.
3838
Module :mod:`ssl`
3939
A TLS/SSL wrapper for socket objects.
4040

41+
.. _socket-addresses:
4142

4243
Socket families
4344
---------------
@@ -903,7 +904,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
903904

904905
Build a pair of connected socket objects using the given address family, socket
905906
type, and protocol number. Address family, socket type, and protocol number are
906-
as for the :func:`~socket.socket` function above. The default family is :const:`AF_UNIX`
907+
as for the :func:`~socket.socket` function. The default family is :const:`AF_UNIX`
907908
if defined on the platform; otherwise, the default is :const:`AF_INET`.
908909

909910
The newly created sockets are :ref:`non-inheritable <fd_inheritance>`.
@@ -999,8 +1000,8 @@ The following functions all create :ref:`socket objects <socket-objects>`.
9991000

10001001
Duplicate the file descriptor *fd* (an integer as returned by a file object's
10011002
:meth:`~io.IOBase.fileno` method) and build a socket object from the result. Address
1002-
family, socket type and protocol number are as for the :func:`~socket.socket` function
1003-
above. The file descriptor should refer to a socket, but this is not checked ---
1003+
family, socket type and protocol number are as for the :func:`~socket.socket` function.
1004+
file descriptor should refer to a socket, but this is not checked ---
10041005
subsequent operations on the object may fail if the file descriptor is invalid.
10051006
This function is rarely needed, but can be used to get or set socket options on
10061007
a socket passed to a program as standard input or output (such as a server
@@ -1564,8 +1565,8 @@ to sockets.
15641565

15651566
.. method:: socket.bind(address)
15661567

1567-
Bind the socket to *address*. The socket must not already be bound. (The format
1568-
of *address* depends on the address family --- see above.)
1568+
Bind the socket to *address*. The socket must not already be bound. The format
1569+
of *address* depends on the address family --- see :ref:`socket-addresses`.
15691570

15701571
.. audit-event:: socket.bind self,address socket.socket.bind
15711572

@@ -1598,8 +1599,8 @@ to sockets.
15981599

15991600
.. method:: socket.connect(address)
16001601

1601-
Connect to a remote socket at *address*. (The format of *address* depends on the
1602-
address family --- see above.)
1602+
Connect to a remote socket at *address*. The format of *address* depends on the
1603+
address family --- see :ref:`socket-addresses`.
16031604

16041605
If the connection is interrupted by a signal, the method waits until the
16051606
connection completes, or raises a :exc:`TimeoutError` on timeout, if the
@@ -1674,16 +1675,16 @@ to sockets.
16741675
.. method:: socket.getpeername()
16751676

16761677
Return the remote address to which the socket is connected. This is useful to
1677-
find out the port number of a remote IPv4/v6 socket, for instance. (The format
1678-
of the address returned depends on the address family --- see above.) On some
1679-
systems this function is not supported.
1678+
find out the port number of a remote IPv4/v6 socket, for instance. The format
1679+
of the address returned depends on the address family --- see :ref:`socket-addresses`.
1680+
On some systems this function is not supported.
16801681

16811682

16821683
.. method:: socket.getsockname()
16831684

16841685
Return the socket's own address. This is useful to find out the port number of
1685-
an IPv4/v6 socket, for instance. (The format of the address returned depends on
1686-
the address family --- see above.)
1686+
an IPv4/v6 socket, for instance. The format of the address returned depends on
1687+
the address family --- see :ref:`socket-addresses`.
16871688

16881689

16891690
.. method:: socket.getsockopt(level, optname[, buflen])
@@ -1795,7 +1796,8 @@ to sockets.
17951796
where *bytes* is a bytes object representing the data received and *address* is the
17961797
address of the socket sending the data. See the Unix manual page
17971798
:manpage:`recv(2)` for the meaning of the optional argument *flags*; it defaults
1798-
to zero. (The format of *address* depends on the address family --- see above.)
1799+
to zero. The format of *address* depends on the address family --- see
1800+
:ref:`socket-addresses`.
17991801

18001802
.. versionchanged:: 3.5
18011803
If the system call is interrupted and the signal handler does not raise
@@ -1925,8 +1927,8 @@ to sockets.
19251927
new bytestring. The return value is a pair ``(nbytes, address)`` where *nbytes* is
19261928
the number of bytes received and *address* is the address of the socket sending
19271929
the data. See the Unix manual page :manpage:`recv(2)` for the meaning of the
1928-
optional argument *flags*; it defaults to zero. (The format of *address*
1929-
depends on the address family --- see above.)
1930+
optional argument *flags*; it defaults to zero. The format of *address*
1931+
depends on the address family --- see :ref:`socket-addresses`.
19301932

19311933

19321934
.. method:: socket.recv_into(buffer[, nbytes[, flags]])
@@ -1941,7 +1943,7 @@ to sockets.
19411943
.. method:: socket.send(bytes[, flags])
19421944

19431945
Send data to the socket. The socket must be connected to a remote socket. The
1944-
optional *flags* argument has the same meaning as for :meth:`recv` above.
1946+
optional *flags* argument has the same meaning as for :meth:`recv`.
19451947
Returns the number of bytes sent. Applications are responsible for checking that
19461948
all data has been sent; if only some of the data was transmitted, the
19471949
application needs to attempt delivery of the remaining data. For further
@@ -1956,7 +1958,7 @@ to sockets.
19561958
.. method:: socket.sendall(bytes[, flags])
19571959

19581960
Send data to the socket. The socket must be connected to a remote socket. The
1959-
optional *flags* argument has the same meaning as for :meth:`recv` above.
1961+
optional *flags* argument has the same meaning as for :meth:`recv`.
19601962
Unlike :meth:`send`, this method continues to send data from *bytes* until
19611963
either all data has been sent or an error occurs. ``None`` is returned on
19621964
success. On error, an exception is raised, and there is no way to determine how
@@ -1977,9 +1979,9 @@ to sockets.
19771979

19781980
Send data to the socket. The socket should not be connected to a remote socket,
19791981
since the destination socket is specified by *address*. The optional *flags*
1980-
argument has the same meaning as for :meth:`recv` above. Return the number of
1981-
bytes sent. (The format of *address* depends on the address family --- see
1982-
above.)
1982+
argument has the same meaning as for :meth:`recv`. Return the number of
1983+
bytes sent. The format of *address* depends on the address family --- see
1984+
:ref:`socket-addresses`.
19831985

19841986
.. audit-event:: socket.sendto self,address socket.socket.sendto
19851987

0 commit comments

Comments
 (0)