You're free to get over yourself any time, y'know.I am not affiliated with GEORGE ROBOTICS LIMITED (PLC).Yes, but you could help to improve the docs. Micropython benefits of it.
So let's compare what the docs for socket.send say:
MicroPython:
Python: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”).
C library (man 2 send)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.
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.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 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