Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8062

MicroPython • Re: Size of web page handled by a Pico W server?

$
0
0
Yes, but you could help to improve the docs. Micropython benefits of it.
I am not affiliated with GEORGE ROBOTICS LIMITED (PLC).
You're free to get over yourself any time, y'know.

So let's compare what the docs for socket.send say:

MicroPython:
socket.send(bytes)

Send data to the socket. The socket must be connected to a remote socket. Returns number of bytes sent, which may be smaller than the length of data (“short write”).
Python:
socket.send(bytes[, flags])
Send data to the socket. The socket must be connected to a remote socket. The optional flags argument has the same meaning as for recv() above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. For further information on this topic, consult the Socket Programming HOWTO.
C library (man 2 send)
RETURN VALUE
On success, these calls return the number of bytes sent. On error, -1 is returned, and errno is set to indicate the error.
So both the MicroPython and Python docs warn about checking the return value. The C library doesn't. A fraction further down the MicroPython socket reference it's mentioned that socket.write(buf) is preferred, as it will try to write all of the data, but may fail with a non-blocking socket.

So who has the execrable documentation, really?

It's the official Raspberry Pi Ltd Connecting to the Internet with Raspberry Pi Pico W document which still uses send() and write() without checking return codes. Of course, this is all a conspiracy of "Big MicroPython", somehow ...

Statistics: Posted by scruss — Sat Mar 15, 2025 4:40 pm



Viewing all articles
Browse latest Browse all 8062

Trending Articles