View Full Version : fsockopen() issue

09-22-2005, 02:15 AM
I get the following PHP errors when trying to connect to MSN's servers via port 1863:

Warning: fsockopen(): php_hostconnect: connect failed in /home/httpd/vhosts/mediamogulsweb.com/httpdocs/client/block_checker2.php on line 7

Warning: fsockopen(): unable to connect to messenger.hotmail.com:1863 in /home/httpd/vhosts/mediamogulsweb.com/httpdocs/client/block_checker2.php on line 7

This is the code that I'm using to connect:

$link = "messenger.hotmail.com";

$GLOBALS['connect'] = fsockopen($link, 1863, &$errno, &$errstr, 20);

I am wondering if there is some PHP directive that is not allowing me to execute this code properly...My server is remotely hosted, so perhaps I need to contact my web hosting provider? Or is this a coding issue?

Thanks for any advice.

09-22-2005, 05:28 AM
What version of PHP are you running? Here (http://us3.php.net/fsockopen) is an interesting tidbit from the manual:

As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl://' or 'tls://' to use an SSL or TLS client connection over TCP/IP to connect to the remote host.
Don't know if that helps or not. You might want to read the rest of what it says about fsockopen while you're at it. :)

09-22-2005, 08:41 AM
I tried adding those prefixes to the hostname, but they didn;t help....

I modified my code slightly to echo the errors triggered by fsockopen():

$link = "messenger.hotmail.com";

$GLOBALS['connect'] = fsockopen($link, 1863, $errno, $errstr, 50);
if (!$GLOBALS['connect'])
echo "$errstr ($errno)<br>";

I still get the same PHP warnings as before, but at least now I get an actual indication of what the problem is....echo "$errstr ($errno)<br>"; returns:

Connection timed out (110)

I tried bumping up the timout parameter in fsockopen() but that didn;t seem to help...

any other ideas?