I’m experiencing trouble connecting a client running on my web server to my WiFly server running on my LAN. I have already proven that I can do the opposite, connect my WiFly as a client to the web server. My goal is to send a signal from my iPhone to my WiFly to turn on and off a switch. I already have tested an iPhone app that communicates with my web server.
First off, I’m running the WiFly_WebServer sketch on WiFly. I have no trouble associating to my network. When I power WiFly on, it automatically associates to my router and indicates this with a slow blink green LED. I have not modified the WebServer sketch other than inputting my ssid and passphrase credential. The WebServer sketch is set to port 80.
I’m using a PHP script on my website that executes when I open the webpage. I inputted my router’s IP address as the host IP address (66.31.xxx.xx) on an open port. I’ve tried using ports such as 81, 45000, 9092, etc., any ports that do not show up as officially reserved under http://en.wikipedia.org/wiki/List_of_TC … rt_numbers. As I understand it, my router will receive a request and through port forwarding will route the request to the identified port. I’ve already specified port forwarding for a private IP address of 192.168.1.104 (WiFly). I’m using an Airport Express. I have checked my router logs and statistics and have not been able to find any evidence of contact after running the PHP script.
Thanks for reading. I would appreciate any suggestions for helping me connect to my WiFly server on my LAN.
Andrew
Below the PHP code I’m using on my website server:
<? // form not yet submitted if (!$submit) { ?>Enter some text:
<input type=“submit”
name=“submit” value=“Send”>
<? } else { // form submitted // where is the socket server? $host="66.31.xxx.xx"; $port = 81; // open a client connection $fp = fsockopen ($host, $port, $errno, $errstr); if (!$fp) { $result = "Error: could not open socket connection"; } else { // get the welcome message fgets ($fp, 1024); // write the user string to the socket fputs ($fp, $message); // get the result $result .= fgets ($fp, 1024); // close the connection fputs ($fp, "END"); fclose ($fp); // trim the result and remove the starting ? $result = trim($result); $result = substr($result, 2); // now print it to the browser } ?>Server said: <? echo $result; ?>
<? } ?>