python - 没有线程的多连接套接字无法识别发送
问题描述
我的代码中有这个错误,我不知道如何摆脱它。该代码使多套接字连接到同一台服务器,但我收到此错误
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
等等。
我也没有使用线程
解决方案
推荐阅读
- flutter-listview - 如何使用颤振创建类别分隔的列表视图构建器
- javascript - 多维浮点数组的正则表达式。每个数组值后匹配空格或无空格
- javascript - 循环遍历Vuejs中的对象数组以获取HTML选择标签
- c# - 字典 TryGetValue 输出参数
- php - Laravel 6 mutator 没有将 null 转换为空字符串
- android - 具有动态占位符的单元 getString
- php - 如何限制foreach循环中的回显字符串
- php - PHP Sorting Algorithm to Arrange Texts no Alphabetical
- python-3.x - How to get access_token from fyers API?
- javascript - Jquery/Javascript global variable not updated from within (nested) function