-1
Good afternoon!
I am studying Python and came across a problem while studying about network (socket library). I have the following piece of code
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('http://data.pr4e.org/', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
mysock.send(cmd)
while True :
data = mysock.recv(512)
if (len(data) < 1) :
break
print(data.decode())
mysock.close()
So I checked all the links work and are without problems, but when running the script an error is shown on the screen
Traceback (most recent call last):
File "C:\Users\Andre\Desktop\PythonMichiganSchool\network\script.py", line 4, in <module>
mysock.connect(('http://data.pr4e.org/', 80))
socket.gaierror: [Errno 11001] getaddrinfo failed
I tried to change the links and test them, rewrote the code and read the library documentation and even some answers here in stackoverflow, but I did not succeed in solving the problem