python - Check if connection is established on port -


I find out whether the port is open, but I'm not sure how it extend also to check whether the connection has established.

  try import socket ip_address_machine = '127.0.0.1' port_to_try = 3389: s = socket.socket (socket.AF_INET, socket.SOCK_STREAM) result = s.connect_ex ((ip_address_machine, Port_to_try) ) Skclose () if (result == 0): print ( "port", port_to_try, "open the machine", ip_address_machine) other: print ( "port", port_to_try, "do not open the machine", Ip_address_machine ): The print ("the machine is off")  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -