当我的应用程序通过所有端口时,它应该打印“完成”。但事实并非如此。这就是我所拥有的:
import time
import socket
import threading
from queue import Queue
printLock = threading.Lock()
q = Queue()
target = input("Enter Ip: ")
def portscan(port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
con = s.connect((target,port))
with printLock:
print("port",port,"open")
con.close()
except:
pass
def threader():
while True:
worker = q.get()
portscan(worker)
q.task_done()
for x in range(10000):
t = threading.Thread(target = threader)
t.daemon = True
t.start()
for worker in range(1,101):
q.put(worker)
q.join()
print("done")