-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Open
Labels
Description
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