473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

fsockopen fails to connect to a valid URL.

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

Th code Used is:
Expand|Select|Wrap|Line Numbers
  1.                                 $fp = fsockopen("alertbox.in", 80);
  2.         if (!$fp) 
  3.         {
  4.            echo "$errstr ($errno)<br />\n";
  5.         } 
  6.         else 
  7.         {
  8.            // $out = "GET / HTTP/1.1\r\n";
  9.            // $out .= "Host: $host\r\n";
  10.            // $out .= "Connection: Close\r\n\r\n";
  11.            $out .=$host."?".$request."\r\n";
  12.            echo $out;
  13.  
  14.            fwrite($fp, $out);
  15.            while (!feof($fp)) 
  16.            {
  17.                echo fgets($fp, 128);
  18.            }
  19.            fclose($fp);
  20.         }
  21.  
can anybody please help me out for this problem? Thanks in advance.
Jan 19 '09 #1
5 3980
Atli
5,058 Expert 4TB
Hi.

I tried your code on my test server and it seemed to work fine.
I got this output when I executed it:
Expand|Select|Wrap|Line Numbers
  1. ?
  2. <center><p><b>Your Pointing Was Successful, Please contact your administrator For Activation.</b></p></center>
Could it be that your server is somehow blocking your connection to this site?
Jan 19 '09 #2
thanks for your reply.
we r trying find it out.
We got the same output now. But SMS is not getting send. All Admin seetings are correct. Can u please help this further?

thanks once again for that fast reply
Jan 19 '09 #3
Atli
5,058 Expert 4TB
Seems that the connection is made and the request is being processed.

Now you just need to find out what you have to send to the server so the SMS gets sent and make sure that is what you are sending.

Somehow I doubt what you are sending in that code is what they want :]
Jan 19 '09 #4
Hi,

In the code fragment there is one statement that prints the url being accessed.

echo $out;

This prints that URL correctly. When I copy that URL and directly give it in the address bar SMS is getting send immediately.

Thank you.
Jan 20 '09 #5
Atli
5,058 Expert 4TB
Ok, so the $out variable is an URL you want to call?

If that is the case, then simply a socket and sending the URL is not the way to do this.If you open a socket like that, you would have to send an actual HTTP request, not just the URL.

To simply call an URL, you can use the file_get_contents function or the CURL functions.
Like, for example:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $url = "http://www.example.com";
  3. if($response = file_get_contents($url)) {
  4.   echo "Success!<pre>", $response, "</pre>";
  5. }
  6. else {
  7.   echo "Failed!";
  8. }
  9. ?>
Jan 20 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nima | last post by:
Hi all, I'm trying to open, read and extract information from a website (maximum and minimum temps from http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV10450.txt )... Could anyone give me some...
2
by: Loopy | last post by:
I'm trying to write a script that will connect to an external site so that I can get access referer information in a database on another one of my sites. I got errors, so I tried to write a script...
9
by: fipaj1992 | last post by:
Hi! I have very big problem with fsockopen() function. It is very important... That's code: <?php $test = fsockopen ('chrome.pl', '8080'); ?>
1
by: Syl | last post by:
Hi group - I have a database table with 4 columns that hold a url. I am selecting each url and I need to check to see if it is valid. I assumed I could use the fsockopen command. I've had to...
5
by: webbyfoot | last post by:
I've a form where users suggest a website by entering the url - and want to redirect them to a 'thanks but no thanks' page if the site doesn't actually exist I tried the following: $fp =...
8
by: Yoko | last post by:
So I am using php version 4.3.9 and lets say i have a file on the server called tester.php so i am using fsockopen to point to that file but it gives me a error below. $fh =...
4
by: MikeofPet | last post by:
I am trying to implement FTP in a PHP script but am unable to make the connection to the remote server. The connection step times out at the fsockopen function. I am not sure if it is relevant but...
6
by: henryrhenryr | last post by:
Hi I'm really hoping for some ideas! I have been setting up phpmailer on my server and it was working nicely on my local server so I uploaded to my live server and tested. The mystery is that...
0
by: smokenlinks | last post by:
I am working on a script and i get this error Warning: fsockopen() : unable to connect to https://www.alertpay.com:443 (Unable to find the socket transport "https" - did you forget to enable it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.