首页 > 解决方案 > 没有线程的多连接套接字无法识别发送

问题描述

我的代码中有这个错误,我不知道如何摆脱它。该代码使多套接字连接到同一台服务器,但我收到此错误

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等等。

我也没有使用线程

标签: pythonpython-3.xsockets

解决方案


推荐阅读