May-13-2022, 08:55 AM
Can anyone offer some assistance because i am working on this port scanner and it seems to run fine but when i sent it to another person they said they are getting a time out error. If anyone doesn't mind looking at the code i can share it with them 
Check code below. thanks guys and girls

Check code below. thanks guys and girls
#This program does the port scanning from 0 to 1025. #All results will write in file. #Errors is managed by exception and will write to file. import concurrent.futures import socket import threading import time import sys print_lock = threading.Lock() ip = input("Enter the IP to scan: ") #ask user ip for scanning f = open("scanresult.txt", "w") #open file to write results print("Scanned IP: ", ip, file=f) def scan(ip, port): scanner = socket.socket(socket.AF_INET, socket.SOCK_STREAM) scanner.settimeout(1) try: scanner.connect((ip, port)) scanner.close() with print_lock: print(f"[{port}]" + f" is open", file=f) except KeyboardInterrupt: #manage exception print("\n Exiting Program !!!!", file=f) sys.exit() except socket.gaierror: print("\n Host name Could Not Be Resolved !!!!", file=f) sys.exit() except socket.herror: print("\n Host is not available !!!!", file=f) sys.exit() except socket.timeout: print("\n TIMEOUT !!!!", file=f) sys.exit() except: pass startscan = time.time() #time when scan started print(time.ctime(), file=f) #print date and time when scan started with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor: #actual scanning for port in range(1025): executor.submit(scan, ip, port + 1) break endscan = time.time() #time when scan ended print(time.ctime(), file=f) #print date and time when scan ended print("Scan time is: ", int(endscan) - int(startscan), file=f) f.close() #close file after writing scan(ip, port)