Is this the right way to connect to a socket?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/563153/socket-create-vs-fsockopen-php">socket_create vs. fsockopen php</a>  </p>
</blockquote>



<p>Is this the right way to connect to a socket in PHP.</p>

<pre><code>&lt;?php
$fp = fsockopen($ipaddress,$port, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)&lt;br /&gt;\n";
} 
else{
echo "Socket connected";
}
echo fread($fp, 100);
?&gt;
</code></pre>

<p>If yes, then what is the difference between this approach and the approach specified here:
<a href="http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/" rel="nofollow">http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/</a>
Thanks</p>
