I was trying to make a simple port scanner, but when it found a port open, the errors that appeared changed from [WinError 10061] No connection could be made because the target machine actively refused them to [WinError 10038] An operation was attempted on some item that is not a socket!
def ScanPorts(host,Range):
i=1
while i <= int(Range):
try:
s.connect((host , i))
print(i)
lista_portas.append(i)
s.close()
time.sleep(1)
print(i)
except Exception as e :
print(str(i) + ":" + str(e))
i=i+1
for i in lista_portas:
print('Porta:',i,"aberta")