import socket for port in range(1,65536): try: conn= socket.socket(2,1) conn.connect('192.168.1.100',port) print ('Tcp port %d is open' %port) except: pass
import socket
for port in range(1,65536):
try:
conn = socket.socket(2 , 1)
conn.connect('192.168.1.100' , port)
print ('Tcp port %d is open'%port)
except:
pass
finally:
conn.close()