Skip to content

Commit 6947a7f

Browse files
committed
docs/usocket: Dedent Methods section.
This was apparently of an ::only directive which was later removed.
1 parent f23c47f commit 6947a7f

1 file changed

Lines changed: 95 additions & 95 deletions

File tree

docs/library/usocket.rst

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -117,146 +117,146 @@ class socket
117117
Methods
118118
-------
119119

120-
.. method:: socket.close
120+
.. method:: socket.close
121121

122-
Mark the socket closed. Once that happens, all future operations on the socket
123-
object will fail. The remote end will receive no more data (after queued data is flushed).
122+
Mark the socket closed. Once that happens, all future operations on the socket
123+
object will fail. The remote end will receive no more data (after queued data is flushed).
124124

125-
Sockets are automatically closed when they are garbage-collected, but it is recommended
126-
to close() them explicitly, or to use a with statement around them.
125+
Sockets are automatically closed when they are garbage-collected, but it is recommended
126+
to close() them explicitly, or to use a with statement around them.
127127

128-
.. method:: socket.bind(address)
128+
.. method:: socket.bind(address)
129129

130-
Bind the socket to address. The socket must not already be bound.
130+
Bind the socket to address. The socket must not already be bound.
131131

132-
.. method:: socket.listen([backlog])
132+
.. method:: socket.listen([backlog])
133133

134-
Enable a server to accept connections. If backlog is specified, it must be at least 0
135-
(if it's lower, it will be set to 0); and specifies the number of unaccepted connections
136-
that the system will allow before refusing new connections. If not specified, a default
137-
reasonable value is chosen.
134+
Enable a server to accept connections. If backlog is specified, it must be at least 0
135+
(if it's lower, it will be set to 0); and specifies the number of unaccepted connections
136+
that the system will allow before refusing new connections. If not specified, a default
137+
reasonable value is chosen.
138138

139-
.. method:: socket.accept()
139+
.. method:: socket.accept()
140140

141-
Accept a connection. The socket must be bound to an address and listening for connections.
142-
The return value is a pair (conn, address) where conn is a new socket object usable to send
143-
and receive data on the connection, and address is the address bound to the socket on the
144-
other end of the connection.
141+
Accept a connection. The socket must be bound to an address and listening for connections.
142+
The return value is a pair (conn, address) where conn is a new socket object usable to send
143+
and receive data on the connection, and address is the address bound to the socket on the
144+
other end of the connection.
145145

146-
.. method:: socket.connect(address)
146+
.. method:: socket.connect(address)
147147

148-
Connect to a remote socket at address.
148+
Connect to a remote socket at address.
149149

150-
.. method:: socket.send(bytes)
150+
.. method:: socket.send(bytes)
151151

152-
Send data to the socket. The socket must be connected to a remote socket.
153-
Returns number of bytes sent, which may be smaller than the length of data
154-
("short write").
152+
Send data to the socket. The socket must be connected to a remote socket.
153+
Returns number of bytes sent, which may be smaller than the length of data
154+
("short write").
155155

156-
.. method:: socket.sendall(bytes)
156+
.. method:: socket.sendall(bytes)
157157

158-
Send all data to the socket. The socket must be connected to a remote socket.
159-
Unlike ``send()``, this method will try to send all of data, by sending data
160-
chunk by chunk consecutively.
158+
Send all data to the socket. The socket must be connected to a remote socket.
159+
Unlike ``send()``, this method will try to send all of data, by sending data
160+
chunk by chunk consecutively.
161161

162-
The behavior of this method on non-blocking sockets is undefined. Due to this,
163-
on MicroPython, it's recommended to use ``write()`` method instead, which
164-
has the same "no short writes" policy for blocking sockets, and will return
165-
number of bytes sent on non-blocking sockets.
162+
The behavior of this method on non-blocking sockets is undefined. Due to this,
163+
on MicroPython, it's recommended to use ``write()`` method instead, which
164+
has the same "no short writes" policy for blocking sockets, and will return
165+
number of bytes sent on non-blocking sockets.
166166

167-
.. method:: socket.recv(bufsize)
167+
.. method:: socket.recv(bufsize)
168168

169-
Receive data from the socket. The return value is a bytes object representing the data
170-
received. The maximum amount of data to be received at once is specified by bufsize.
169+
Receive data from the socket. The return value is a bytes object representing the data
170+
received. The maximum amount of data to be received at once is specified by bufsize.
171171

172-
.. method:: socket.sendto(bytes, address)
172+
.. method:: socket.sendto(bytes, address)
173173

174-
Send data to the socket. The socket should not be connected to a remote socket, since the
175-
destination socket is specified by `address`.
174+
Send data to the socket. The socket should not be connected to a remote socket, since the
175+
destination socket is specified by `address`.
176176

177-
.. method:: socket.recvfrom(bufsize)
177+
.. method:: socket.recvfrom(bufsize)
178178

179-
Receive data from the socket. The return value is a pair (bytes, address) where bytes is a
180-
bytes object representing the data received and address is the address of the socket sending
181-
the data.
179+
Receive data from the socket. The return value is a pair (bytes, address) where bytes is a
180+
bytes object representing the data received and address is the address of the socket sending
181+
the data.
182182

183-
.. method:: socket.setsockopt(level, optname, value)
183+
.. method:: socket.setsockopt(level, optname, value)
184184

185-
Set the value of the given socket option. The needed symbolic constants are defined in the
186-
socket module (SO_* etc.). The value can be an integer or a bytes-like object representing
187-
a buffer.
185+
Set the value of the given socket option. The needed symbolic constants are defined in the
186+
socket module (SO_* etc.). The value can be an integer or a bytes-like object representing
187+
a buffer.
188188

189-
.. method:: socket.settimeout(value)
189+
.. method:: socket.settimeout(value)
190190

191-
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating
192-
point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations
193-
will raise an ``OSError`` exception if the timeout period value has elapsed before the operation has
194-
completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
195-
is put in blocking mode.
191+
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating
192+
point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations
193+
will raise an ``OSError`` exception if the timeout period value has elapsed before the operation has
194+
completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket
195+
is put in blocking mode.
196196

197-
.. admonition:: Difference to CPython
198-
:class: attention
197+
.. admonition:: Difference to CPython
198+
:class: attention
199199

200-
CPython raises a ``socket.timeout`` exception in case of timeout,
201-
which is an ``OSError`` subclass. MicroPython raises an OSError directly
202-
instead. If you use ``except OSError:`` to catch the exception,
203-
your code will work both in MicroPython and CPython.
200+
CPython raises a ``socket.timeout`` exception in case of timeout,
201+
which is an ``OSError`` subclass. MicroPython raises an OSError directly
202+
instead. If you use ``except OSError:`` to catch the exception,
203+
your code will work both in MicroPython and CPython.
204204

205-
.. method:: socket.setblocking(flag)
205+
.. method:: socket.setblocking(flag)
206206

207-
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking,
208-
else to blocking mode.
207+
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking,
208+
else to blocking mode.
209209

210-
This method is a shorthand for certain ``settimeout()`` calls:
210+
This method is a shorthand for certain ``settimeout()`` calls:
211211

212-
* ``sock.setblocking(True)`` is equivalent to ``sock.settimeout(None)``
213-
* ``sock.setblocking(False)`` is equivalent to ``sock.settimeout(0)``
212+
* ``sock.setblocking(True)`` is equivalent to ``sock.settimeout(None)``
213+
* ``sock.setblocking(False)`` is equivalent to ``sock.settimeout(0)``
214214

215-
.. method:: socket.makefile(mode='rb', buffering=0)
215+
.. method:: socket.makefile(mode='rb', buffering=0)
216216

217-
Return a file object associated with the socket. The exact returned type depends on the arguments
218-
given to makefile(). The support is limited to binary modes only ('rb', 'wb', and 'rwb').
219-
CPython's arguments: ``encoding``, ``errors`` and ``newline`` are not supported.
217+
Return a file object associated with the socket. The exact returned type depends on the arguments
218+
given to makefile(). The support is limited to binary modes only ('rb', 'wb', and 'rwb').
219+
CPython's arguments: ``encoding``, ``errors`` and ``newline`` are not supported.
220220

221-
.. admonition:: Difference to CPython
222-
:class: attention
221+
.. admonition:: Difference to CPython
222+
:class: attention
223223

224-
As MicroPython doesn't support buffered streams, values of ``buffering``
225-
parameter is ignored and treated as if it was 0 (unbuffered).
224+
As MicroPython doesn't support buffered streams, values of ``buffering``
225+
parameter is ignored and treated as if it was 0 (unbuffered).
226226

227-
.. admonition:: Difference to CPython
228-
:class: attention
227+
.. admonition:: Difference to CPython
228+
:class: attention
229229

230-
Closing the file object returned by makefile() WILL close the
231-
original socket as well.
230+
Closing the file object returned by makefile() WILL close the
231+
original socket as well.
232232

233-
.. method:: socket.read([size])
233+
.. method:: socket.read([size])
234234

235-
Read up to size bytes from the socket. Return a bytes object. If ``size`` is not given, it
236-
reads all data available from the socket until ``EOF``; as such the method will not return until
237-
the socket is closed. This function tries to read as much data as
238-
requested (no "short reads"). This may be not possible with
239-
non-blocking socket though, and then less data will be returned.
235+
Read up to size bytes from the socket. Return a bytes object. If ``size`` is not given, it
236+
reads all data available from the socket until ``EOF``; as such the method will not return until
237+
the socket is closed. This function tries to read as much data as
238+
requested (no "short reads"). This may be not possible with
239+
non-blocking socket though, and then less data will be returned.
240240

241-
.. method:: socket.readinto(buf[, nbytes])
241+
.. method:: socket.readinto(buf[, nbytes])
242242

243-
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
244-
that many bytes. Otherwise, read at most ``len(buf)`` bytes. Just as
245-
``read()``, this method follows "no short reads" policy.
243+
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
244+
that many bytes. Otherwise, read at most ``len(buf)`` bytes. Just as
245+
``read()``, this method follows "no short reads" policy.
246246

247-
Return value: number of bytes read and stored into ``buf``.
247+
Return value: number of bytes read and stored into ``buf``.
248248

249-
.. method:: socket.readline()
249+
.. method:: socket.readline()
250250

251-
Read a line, ending in a newline character.
251+
Read a line, ending in a newline character.
252252

253-
Return value: the line read.
253+
Return value: the line read.
254254

255-
.. method:: socket.write(buf)
255+
.. method:: socket.write(buf)
256256

257-
Write the buffer of bytes to the socket. This function will try to
258-
write all data to a socket (no "short writes"). This may be not possible
259-
with a non-blocking socket though, and returned value will be less than
260-
the length of ``buf``.
257+
Write the buffer of bytes to the socket. This function will try to
258+
write all data to a socket (no "short writes"). This may be not possible
259+
with a non-blocking socket though, and returned value will be less than
260+
the length of ``buf``.
261261

262-
Return value: number of bytes written.
262+
Return value: number of bytes written.

0 commit comments

Comments
 (0)