Sockets are virtual ports that (potentially) exist at an Internet address. They are numbered sequentially. The ports below 1024 are reserved for standard purposes; the ports above that number are available for applications to use dynamically.
For example, Telnet ordinarily listens to port 23 and a Web server listens to port 80.
fsockopen() lets you connect to a port as if it were a file and read/write data. If you know what protocol is expected at the other end, you may be able to do something useful.
Here are a couple of examples.
http://yelvington.com/headlines.php3
The code on that page explains how to fetch RSS feeds and display them as bulleted lists on your PHP page. For an example of an RSS feed, see http://www.phpbuilder.com/linking.php.
The following code will look up the owner of a numeric Internet address by using the "whois" service on port 43 at arin.net. $domain should be a string containing a valid Internet address, such as 64.208.162.98.
It tells me you're connecting from Tromaville.com, the famous B-movie factory.
<?PHP
function getnumericaddress($domain)
{
echo "<b>Network number information from ARIN</b>";
echo "<PRE>";
$fp = fsockopen("whois.arin.net", 43, &$errno, &$errstr, 10);
if(!$fp)
{
echo "Could not open connection to $server on port 43.\n";
echo "$errstr ($errno)<br>\n";
}
else
{
fputs($fp,"$domain\r\n");
while(!feof($fp))
{
echo fgets($fp,128);
}
fclose($fp);
}
echo "</PRE>";
}