Я пытаюсь просканировать ip su bnet, используя сокет lib на python3 .7.6, но выдает OSError.
Stacktrace
File "scanny.py", line 88, in scanSubnet
self.session.connect((host, 497))
OSError: [WinError 10022] An invalid argument was supplied
КОД
Класс __init __
def __init__(self, openedPorts=[], timeout=0.1):
self.host = '#!' #default value
self.port = '#!'
self.portRange = '#!'
self.openedPorts = openedPorts
self.noGAIerror = True
self.session = s.socket()
self.session.settimeout(timeout)
Проблемат c код
def scanSubnet(self):
hosts=[]
cp("\tIP: ", color="green", end='') #termcolor's cprint
host = input()
i = 1
while i <= 256:
host = str(host[:-len(str(i-1))] + str(i-1))
cp(host,color="yellow")
try:
self.session.connect((host, 497))
cp("\n\t[" + host + "] OK",color="green")
hosts.append(host)
self.session.close()
self.__init__()
except s.timeout: pass # s = socket
except s.gaierror: continue
Как мне этого избежать?