OSError: [Errno 22] EINVAL

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
bdjens
Posts: 3
Joined: Wed Dec 08, 2021 7:25 pm

OSError: [Errno 22] EINVAL

Post by bdjens » Wed Dec 08, 2021 7:29 pm

I am trying to carry 3 variables by the GET method on a pbc. and it gives me this error. Can you help me? I'm going crazy
OSError: [Errno 22] EINVAL

host = "domain.com/test/test.php"
url = "domain.com/test/test.php?a=" + str(vara) + "&b=" + str(varb) + "&c=" + str(varc)
port = 80
print(url)
s = socket.socket()
s.connect((host, port))
message = "GET /200 HTTP/1.1\r\nHost: {}\r\nConnection: close\r\n\r\n"
s.write(message.format(url))
print(s.read(256))
s.close()
Last edited by bdjens on Sun Dec 12, 2021 6:21 am, edited 1 time in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: OSError: [Errno 22] EINVAL

Post by pythoncoder » Thu Dec 09, 2021 10:23 am

See the docs re socket.getaddrinfo.
Peter Hinch
Index to my micropython libraries.

bdjens
Posts: 3
Joined: Wed Dec 08, 2021 7:25 pm

Re: OSError: [Errno 22] EINVAL

Post by bdjens » Sun Dec 12, 2021 4:42 am

thanks for the information
But, when I put it, it tells me that it is not declared. AF_INET

socket(AF_INET, SOCK_STREAM)
s.connect(socket.getaddrinfo(url, 80)[0][-1])


I am programming on an A9G module, so I am very limited in installing libraries.

It always gives me an error.

I'm desperate, I can't get it to work in any way ... I'm not good at this

bdjens
Posts: 3
Joined: Wed Dec 08, 2021 7:25 pm

Re: OSError: [Errno 22] EINVAL

Post by bdjens » Sun Dec 12, 2021 6:19 am

when the host is of the form, domain.com gives a connection error, it gives me an answer that does not exist, however, when the host is domain.com/test/test.php, for the code

what difference is there between host and url?

Post Reply