OSError: [Errno 22] EINVAL, socket.SOCK_RAW

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
mercan001
Posts: 7
Joined: Sat May 04, 2019 8:42 am

OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by mercan001 » Sat May 04, 2019 9:06 am

Hi,
I have little experience with micropython, i'm working with thonny and writing a code but receive error report. What is wrong?

>>> import socket
>>> socket.socket(socket.AF_INET,socket.SOCK_RAW,0)
Traceback (most recent call last):

File "<stdin>", line 1, in <module>

OSError: [Errno 22] EINVAL

>>>
Last edited by mercan001 on Thu May 09, 2019 3:07 pm, edited 1 time in total.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by jimmo » Sat May 04, 2019 9:58 am

Have you seen the tutorial at https://docs.micropython.org/en/latest/ ... k_tcp.html

What sort of server are you trying to connect to?

mercan001
Posts: 7
Joined: Sat May 04, 2019 8:42 am

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by mercan001 » Sat May 04, 2019 10:08 am

Yes, I have seen. I don't want to connect to the server. If i wanted it i write different code.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by jimmo » Sat May 04, 2019 1:56 pm

Unfortunately SOCK_RAW is not supported -- see https://github.com/micropython/micropyt ... wip.c#L795

I don't know the history, especially why the implementation is partially commented out (perhaps it wasn't deemed important enough, so it's disabled to keep the code size small?).

mercan001
Posts: 7
Joined: Sat May 04, 2019 8:42 am

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by mercan001 » Sun May 05, 2019 6:43 am

Thank you for your answers, but this is bad news. :(
Whereas I have to send raw code to net! I wonder if I can do it in a different way? Is there another way?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by jimmo » Sun May 05, 2019 7:07 am

I guess you could try building the firmware yourself and enable those lines? Search modlwip.c for any line containing the word "raw".

mercan001
Posts: 7
Joined: Sat May 04, 2019 8:42 am

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by mercan001 » Sun May 05, 2019 6:44 pm

I do not know to build firmware myself.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by jimmo » Mon May 06, 2019 6:05 am

If you're interested in learning more about the process, the build instructions are here: https://github.com/micropython/micropyt ... ts/esp8266

mercan001
Posts: 7
Joined: Sat May 04, 2019 8:42 am

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by mercan001 » Mon May 06, 2019 7:12 am

These linux and macOS operations i don't know linux.

mercan001
Posts: 7
Joined: Sat May 04, 2019 8:42 am

Re: OSError: [Errno 22] EINVAL, socket.SOCK_RAW

Post by mercan001 » Mon May 06, 2019 7:18 am

I guess i will learn another programming language for esp. It will be the fourth language. ;)

Post Reply