首页 > 代码库 > Python探测主机端口是否存活

Python探测主机端口是否存活

#!/usr/bin/python3import socketsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)result = sock.connect_ex((‘10.10.130.111‘,8080))if 0 == result:   print("Port is open")else:   print("Port is not open,return code:%s" % result)

  

Python探测主机端口是否存活