没有线程的多连接套接字无法识别发送

时间:2019-03-16 14:34:39

标签: python python-3.x sockets

我的代码中有此错误,我不确定如何摆脱它。代码使多套接字连接到同一服务器,但出现此错误

Traceback (most recent call last):
  File "C:\Users\user\Desktop\file.py", line 73, in <module>
    connect_to(target, port)
  File "C:\Users\user\Desktop\file.py", line 68, in connect_to
    int_nob.send("User-Agent: {}\r\n".format(random.choice(user_agents)).encode("utf-8"))
AttributeError: 'NoneType' object has no attribute 'send

受影响的代码部分

def connect_to(ip, port1):
    int_nob = int(200)#num of bots
    for x in range(0, int_nob):
        print(int(int_nob))

        int_nob -= 1
        int_nob = s.connect((ip, port1))
        int_nob.send("User-Agent: {}\r\n".format(random.choice(user_agents)).encode("utf-8"))
        if int_nob == 0:
            print(list_of_sockets)
            print("resending sockets of " + int_nob)
while True:
    connect_to(target, port)

我已经拥有了所有  import os import random s = socket.socket(AF_INET, socket.SOCK_STREM) port = 445等。

我也不使用线程

0 个答案:

没有答案