How to improve performance of port scanner executed on page load
<p>I have this small function for detecting a visitors port. The problem is that it's far too slow. It increases the page load time by about 3 seconds; naturally this is unacceptable.</p>

<p>Can anybody improve upon this for a better page load time?</p>

<pre><code>function ipProxyPortCheck($ip){
    $timeout = 1;
    $ports = array(80,3128,8080);
    $flag = 0;
    foreach($ports as $port){
        @$fp = fsockopen($ip,$port,$errno,$errstr,$timeout);
        if(!empty($fp)){
            $flag = 1;
            fclose($fp);
        }
    }
    return $flag;
}
</code></pre>
