← index #16803Issue #18025
Off-topic · high · value 2.729
QUERY · ISSUE

UNIX build missing socket.sendall() method

openby petrkropened 2025-02-24updated 2025-06-04
bugport-unix

Port, board and/or hardware

UNIX

MicroPython version

$ micropython 
MicroPython v1.24.1 on 2025-02-24; linux [GCC 14.2.1] version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import socket
>>> s = socket.socket()
>>> dir(s)
['__class__', 'close', 'read', 'readinto', 'readline', 'send', 'write', 'accept', 'bind', 'connect', 'fileno', 'listen', 'makefile', 'recv', 'recvfrom', 'sendto', 'setblocking', 'setsockopt', 'settimeout']
>>> 

Regarding to documentation, sendall is supported. On ESP32 build it is available

MicroPython v1.24.1 on 2024-11-29; Generic ESP32 module with ESP32                                        
Type "help()" for more information.                                                                       
>>>                                                                                                       
>>> import socket                                                                                         
>>> s = socket.socket()                                                                                                                                                                                          
>>> dir (s)                                                                                                                                                                                                      
['__class__', 'close', 'read', 'readinto', 'readline', 'send', 'write', '__del__', 'accept', 'bind', 'conn
ect', 'fileno', 'listen', 'makefile', 'recv', 'recvfrom', 'sendall', 'sendto', 'setblocking', 'setsockopt'
, 'settimeout']                                                                                           

Unix build was created by using AUR package https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=micropython

Reproduction

Build unix version of uPy
import socket

try to call sendall(packet)

Expected behaviour

Method will be there, so do not need rewrite libraries just for one port

Observed behaviour

what is this ?

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

socket.bind for AF_UNIX requires raw sockaddr struct

openby osresearchopened 2025-09-01updated 2025-09-02
bug

Port, board and/or hardware

unix

MicroPython version

MicroPython v1.26.0 Unix port, standard variant.

Reproduction

On real python this works to create a socket in /tmp/socket:

import socket

sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
sock.bind("/tmp/socket")

For micropython's unix port it requires that the bind() argument be a raw sockaddr struct:

import socket
import struct

sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
sock.bind(struct.pack("H", socket.AF_UNIX) + "/tmp/socket".encode())

Expected behaviour

The socket in /tmp/socket would be created.

Observed behaviour

% ./build/micropython-1.26.0/ports/unix/build-standard/micropython ./sockdemo.py 
Traceback (most recent call last):
  File "./sockdemo.py", line 4, in <module>
OSError: [Errno 22] EINVAL

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied