title: Why do I get no output for my program
body: <p>I use <code>socket</code> to create a tcp connection, and check if a server port of 443 is open.</p>
  
  <pre><code>#!/usr/bin/env python
  import socket
  import subprocess
  import sys
  from datetime import datetime
  
  subprocess.call('clear', shell=True)
  
  remoteServer    = raw_input("Enter a remote host to scan: ")
  remoteServerIP  = socket.gethostbyname(remoteServer)
  
  print "-" * 60
  print "Please wait, scanning remote host", remoteServerIP
  print "-" * 60
  
  t1 = datetime.now()
  
  try:
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      result = sock.connect_ex((remoteServerIP, 443))
      if result == 0:
          print "Port {443}: Open"
      else:
          print "Port {443}: Close"
      sock.close()
  
  except KeyboardInterrupt:
      print "You pressed Ctrl+C"
      sys.exit()
  
  except socket.gaierror:
      print 'Hostname could not be resolved. Exiting'
      sys.exit()
  
  except socket.error:
      print "Couldn't connect to server"
      sys.exit()
  
  t2 = datetime.now()
  total =  t2 - t1
  print 'Scanning Completed in: ', total
  </code></pre>
  
  <p>Sometimes I got output with <code>open</code> or <code>close</code>, but sometime I got no output. For example, I input <code>64.233.160.2</code> or <code>64.233.160.3</code>, no <code>open</code> or <code>close</code> output. what's wrong with me?</p>