我想检查一个特定的套接字是打开还是关闭了一个 url,但是每当我尝试连接它时都会给我这个错误:socket.gaierror: [Errno 11001] getaddrinfo failed
。
我不明白为什么会这样。
def checkSockets(url):
a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
location = (url, 80)
res_check = a_socket.connect_ex(location)
if res_check == 0:
print(0)
else:
print(1)
a_socket.close()
checkSockets("https://www.youtube.com")