Skip to content

Commit 0d10e53

Browse files
committed
docs/usocket: Describe address format once at the beginning.
Different ports may have different formats.
1 parent 92497bf commit 0d10e53

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

docs/library/usocket.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ This module provides access to the BSD socket interface.
1010
See corresponding `CPython module <https://docs.python.org/3/library/socket.html>`_ for
1111
comparison.
1212

13+
Socket address format(s)
14+
------------------------
15+
16+
Functions below which expect a network address, accept it in the format of
17+
`(ipv4_address, port)`, where `ipv4_address` is a string with dot-notation numeric
18+
IPv4 address, e.g. ``"8.8.8.8"``, and port is integer port number in the range
19+
1-65535. Note the domain names are not accepted as `ipv4_address`, they should be
20+
resolved first using ``socket.getaddrinfo()``.
21+
1322
Functions
1423
---------
1524

@@ -85,8 +94,7 @@ Methods
8594

8695
.. method:: socket.bind(address)
8796

88-
Bind the socket to address. The socket must not already be bound. The format of ``address``
89-
is: ``(ipv4 address, port)``
97+
Bind the socket to address. The socket must not already be bound.
9098

9199
.. method:: socket.listen([backlog])
92100

@@ -104,7 +112,7 @@ Methods
104112

105113
.. method:: socket.connect(address)
106114

107-
Connect to a remote socket at address. The format of address is: ``(ipv4 address, port)``
115+
Connect to a remote socket at address.
108116

109117
.. method:: socket.send(bytes)
110118

@@ -122,8 +130,7 @@ Methods
122130
.. method:: socket.sendto(bytes, address)
123131

124132
Send data to the socket. The socket should not be connected to a remote socket, since the
125-
destination socket is specified by address. The ``address`` has the same format as the
126-
rest of the methods, see above.
133+
destination socket is specified by `address`.
127134

128135
.. method:: socket.recvfrom(bufsize)
129136

0 commit comments

Comments
 (0)