Making a Fast Port Scanner
问题 So I'm making a port scanner in python... import socket ip = "External IP" s = socket.socket(2, 1) #socket.AF_INET, socket.SOCK_STREAM def porttry(ip, port): try: s.connect((ip, port)) return True except: return None for port in range(0, 10000): value = porttry(ip, port) if value == None: print("Port not opened on %d" % port) else: print("Port opened on %d" % port) break raw_input() But this is too slow, I want to somehow be able to some how close or break code after a period of time of not