我一直在尝试运行下面附带的python代码,但我一直收到错误。有人可以告诉我这是什么问题或者我该如何解决?谢谢!
代码:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.py4inf.com', 80))
mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n')
while True:
data = mysock.recv(512)
if ( len(data) < 1 ) :
break
print data;
mysock.close()
Error I get when I run the code
错误:
Traceback (most recent call last):
File "C:\Users\******\Desktop\Python\Programs\socket2.py", line 4, in <module>
mysock.connect(('www.py4inf.com', 80))
File "C:\Python27\lib\socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno 11001] getaddrinfo failed