Hi,
I'm quite new to PHP and I'm trying to access a web page to read some data off it.
My code is:
$cfgServer = "http://www.example.com";
$cfgPort = 80;
$cfgTimeOut = 10;
// open a socket
if(!$cfgTimeOut)
// without timeout
$handle = fsockopen($cfgServer, $cfgPort);
else
// with timeout
$handle = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
if(!$handle) {
echo "<p>Connexion to " . $cfgServer . " failed</p>";
echo "<p>Handle is :[" . $handle . "]</p>";
exit();
}
I just cannot get this to open a socket and allow me to start reading from the $handle. It keeps telling me that the connnection failed.
Am I doing something wrong or does the server I'm uing not allow this?
Thanks Charles