Hey everyone,
This question sort of covers both ServerFault.com and here, but this seems more programming than server. I set up my home computer to run Apache server. It answers to port 5900, which has been port forwarded from my wireless router. I then set up a Dynamic DNS server to continually update what the IP address of my home network is. I know that part works, because I used a different computer on a different wireless network, and was able to access my server's index page using MYURL.com:5900.
My goal is to now send a message to my home server. I've written a script on my home server, where if I send it a POST message, it will save that message to a file. In other words, the series of events should go like this:
- I log on to my web page, write text in a Input, and hit a send button
- The message gets passed to my web site's server.
- My server runs a script that uses CURL to send the message as a POST to my home server's DDNS
- The server at home takes the post, and runs a script which writes it to a file.
I know how to do 1,2 and 4. I've been trying to get 3 to work and can't. I can't even get CURL to read my home server's index.html. Here's the code I've used with CURL (Using PHP):
$string = 'http://MYURL.com';
echo "sending to " . $string . '<br/>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PORT, 5900);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
if(curl_error($ch))
{
echo curl_error($ch);
}
echo $response;
curl_close($ch);
I tested this with google.com, and the default port, and it worked fine. It echoed the html given to me by google. When I run it on my home server's DNS, however, it always times out. When I don't add a time out, it said it couldn't connect. This is using the exact same URL that, when put into a browser, correctly sends me my home server's index.html.
Does anyone know what's going wrong? Also, if there was a better way to do this, what is it?
I know this was a long question, so thank you so much.
Ethan