title: Implementation of Port scan in Python
body: <p>I have a program that scans for open ports on remote host.
  It will take long time to complete the scan.I want to make it work fast.</p>
  <p>Here's my code:</p>
  <h1>Port Scan</h1>
  <pre><code>import socket
  import subprocess
  
  host = input(&quot;Enter a remote host to scan: &quot;)
  hostIP = socket.gethostbyname(host)
  
  print(&quot;Please wait, scanning remote host&quot;, hostIP)
  
  try:
      for port in range(1,1024):
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      result = sock.connect_ex((hostIP, port))
      if result == 0:
          print(&quot;Port: \t Open&quot;.format(port))
          sock.close()
  </code></pre>
  <p>Could one of you Python wizards help me with this.
  Advance Thanks.</p>