title: Identifying listening ports using Python
body: <p>In translating some scripts from bash, I am encountering many uses of netstat -an to find if one of our services is listening.  While I know I can just use subprocess.call or other even popen I would rather use a pythonic solution so I am not leveraging the unix environment we are operating in.</p>
  
  <p>From what I have read the socket module should have something but I haven't seen anything that checks for listening ports.  It could be me not understanding a simple trick, but so far I know how to connect to a socket, and write something that lets me know when that connection failed.  But not necessarily have I found something that specifically checks the port to see if its listening.</p>
  
  <p>Any ideas?</p>