How to check whether a connection for a specific port is open using python
Question: I need to check whether a connection with some port is running on windows. I
can do it using netstat, but how can I check it using python?


Answer: Try like this:

    
    
    import socket;
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    res = s.connect_ex(('192.1.1.1',80))
    if res == 0:
       print "Open"
    else:
       print "Closed"
    

