@@ -39,6 +39,8 @@ is implicit on send operations.
3939 A TLS/SSL wrapper for socket objects.
4040
4141
42+ .. _socket-addresses :
43+
4244Socket families
4345---------------
4446
@@ -788,7 +790,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
788790
789791 Build a pair of connected socket objects using the given address family, socket
790792 type, and protocol number. Address family, socket type, and protocol number are
791- as for the :func: `~socket.socket ` function above . The default family is :const: `AF_UNIX `
793+ as for the :func: `~socket.socket ` function. The default family is :const: `AF_UNIX `
792794 if defined on the platform; otherwise, the default is :const: `AF_INET `.
793795
794796 The newly created sockets are :ref: `non-inheritable <fd_inheritance >`.
@@ -884,8 +886,8 @@ The following functions all create :ref:`socket objects <socket-objects>`.
884886
885887 Duplicate the file descriptor *fd * (an integer as returned by a file object's
886888 :meth: `~io.IOBase.fileno ` method) and build a socket object from the result. Address
887- family, socket type and protocol number are as for the :func: `~socket.socket ` function
888- above. The file descriptor should refer to a socket, but this is not checked ---
889+ family, socket type and protocol number are as for the :func: `~socket.socket ` function.
890+ The file descriptor should refer to a socket, but this is not checked ---
889891 subsequent operations on the object may fail if the file descriptor is invalid.
890892 This function is rarely needed, but can be used to get or set socket options on
891893 a socket passed to a program as standard input or output (such as a server
@@ -1440,8 +1442,8 @@ to sockets.
14401442
14411443.. method :: socket.bind(address)
14421444
1443- Bind the socket to *address *. The socket must not already be bound. ( The format
1444- of *address * depends on the address family --- see above.)
1445+ Bind the socket to *address *. The socket must not already be bound. The format
1446+ of *address * depends on the address family --- see :ref: ` socket-addresses `.
14451447
14461448 .. audit-event :: socket.bind self,address socket.socket.bind
14471449
@@ -1474,8 +1476,8 @@ to sockets.
14741476
14751477.. method :: socket.connect(address)
14761478
1477- Connect to a remote socket at *address *. ( The format of *address * depends on the
1478- address family --- see above.)
1479+ Connect to a remote socket at *address *. The format of *address * depends on the
1480+ address family --- see :ref: ` socket-addresses `.
14791481
14801482 If the connection is interrupted by a signal, the method waits until the
14811483 connection completes, or raises a :exc: `TimeoutError ` on timeout, if the
@@ -1550,16 +1552,16 @@ to sockets.
15501552.. method :: socket.getpeername()
15511553
15521554 Return the remote address to which the socket is connected. This is useful to
1553- find out the port number of a remote IPv4/v6 socket, for instance. ( The format
1554- of the address returned depends on the address family --- see above.) On some
1555- systems this function is not supported.
1555+ find out the port number of a remote IPv4/v6 socket, for instance. The format
1556+ of the address returned depends on the address family --- see :ref: ` socket-addresses `.
1557+ On some systems this function is not supported.
15561558
15571559
15581560.. method :: socket.getsockname()
15591561
15601562 Return the socket's own address. This is useful to find out the port number of
1561- an IPv4/v6 socket, for instance. ( The format of the address returned depends on
1562- the address family --- see above.)
1563+ an IPv4/v6 socket, for instance. The format of the address returned depends on
1564+ the address family --- see :ref: ` socket-addresses `.
15631565
15641566
15651567.. method :: socket.getsockopt(level, optname[, buflen])
@@ -1670,7 +1672,8 @@ to sockets.
16701672 where *bytes * is a bytes object representing the data received and *address * is the
16711673 address of the socket sending the data. See the Unix manual page
16721674 :manpage: `recv(2)` for the meaning of the optional argument *flags *; it defaults
1673- to zero. (The format of *address * depends on the address family --- see above.)
1675+ to zero. The format of *address * depends on the address family --- see
1676+ :ref: `socket-addresses `.
16741677
16751678 .. versionchanged :: 3.5
16761679 If the system call is interrupted and the signal handler does not raise
@@ -1800,8 +1803,8 @@ to sockets.
18001803 new bytestring. The return value is a pair ``(nbytes, address) `` where *nbytes * is
18011804 the number of bytes received and *address * is the address of the socket sending
18021805 the data. See the Unix manual page :manpage: `recv(2)` for the meaning of the
1803- optional argument *flags *; it defaults to zero. ( The format of *address *
1804- depends on the address family --- see above.)
1806+ optional argument *flags *; it defaults to zero. The format of *address *
1807+ depends on the address family --- see :ref: ` socket-addresses `.
18051808
18061809
18071810.. method :: socket.recv_into(buffer[, nbytes[, flags]])
@@ -1816,7 +1819,7 @@ to sockets.
18161819.. method :: socket.send(bytes[, flags])
18171820
18181821 Send data to the socket. The socket must be connected to a remote socket. The
1819- optional *flags * argument has the same meaning as for :meth: `recv ` above .
1822+ optional *flags * argument has the same meaning as for :meth: `recv `.
18201823 Returns the number of bytes sent. Applications are responsible for checking that
18211824 all data has been sent; if only some of the data was transmitted, the
18221825 application needs to attempt delivery of the remaining data. For further
@@ -1831,7 +1834,7 @@ to sockets.
18311834.. method :: socket.sendall(bytes[, flags])
18321835
18331836 Send data to the socket. The socket must be connected to a remote socket. The
1834- optional *flags * argument has the same meaning as for :meth: `recv ` above .
1837+ optional *flags * argument has the same meaning as for :meth: `recv `.
18351838 Unlike :meth: `send `, this method continues to send data from *bytes * until
18361839 either all data has been sent or an error occurs. ``None `` is returned on
18371840 success. On error, an exception is raised, and there is no way to determine how
@@ -1852,9 +1855,9 @@ to sockets.
18521855
18531856 Send data to the socket. The socket should not be connected to a remote socket,
18541857 since the destination socket is specified by *address *. The optional *flags *
1855- argument has the same meaning as for :meth: `recv ` above . Return the number of
1856- bytes sent. ( The format of *address * depends on the address family --- see
1857- above.)
1858+ argument has the same meaning as for :meth: `recv `. Return the number of
1859+ bytes sent. The format of *address * depends on the address family --- see
1860+ :ref: ` socket-addresses `.
18581861
18591862 .. audit-event :: socket.sendto self,address socket.socket.sendto
18601863
0 commit comments