title: TCP connect by using socket return false results
body: <p>Here is the codes which i'm using to scan the port if it's open or not.</p>
  
  <p><a href="https://stackoverflow.com/a/8957053/2203703">https://stackoverflow.com/a/8957053/2203703</a></p>
  
  <p>Could anyone try to fix it please? it seems not work correctly, even if the port is off, the codes always return "successfully connected"</p>
  
  <p>Here is the ip list which i have tested it with port 80</p>
  
  <pre><code>79.142.126.3 //Connection refused 
  222.165.195.103 //Connection refused
  64.75.193.162 //Connection refused
  118.97.197.146 //Port is open
  222.134.154.103 //Connection timed out 
  173.0.59.170 //Port is open
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>5 sockets connected successfully
  79.142.126.3 connected successfully
  222.165.195.103 connected successfully
  64.75.193.162 connected successfully
  118.97.197.146 connected successfully
  173.0.59.170 connected successfully
  </code></pre>
  
  <p>Codes looks fine, but i really can't find the problem.</p>
  
  <p>Any help please?</p>