I am new to sockets and fsockopen(). I am trying to send SMS using a gateway. But the fsockopen always shows the following error.


Warning: fsockopen() [function.fsockopen]: unable to connect to alertbox.in:80
(A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\wamp\www\pro\SendSMS.php on line 45

Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\pro\SendSMS.php on line 45

The code Used is:

$fp = fsockopen("alertbox.in", 80);
if (!$fp) 
{
echo "$errstr ($errno)<br />\n";
} 
else 
{
// $out = "GET / HTTP/1.1\r\n";
// $out .= "Host: $host\r\n";
// $out .= "Connection: Close\r\n\r\n";
$out .=$host."?".$request."\r\n";
echo $out;

fwrite($fp, $out);
while (!feof($fp)) 
{
echo fgets($fp, 128);
}
fclose($fp);
}

can anybody please help me out for this problem? Thanks in advance.

When I tried it on my server, it worked. Are you sure that the machine you are doing this on is able to access alertbox.in ? The error seems to point to the computer not being able to reach that address.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.