Hi, I am working on an iPhone game which is depended on a LAMP server. I want to create a "event" based system where the apache server sends an event to the iphone.
For this, I am thinking of using "CFStreamCreatePairWithSocketToHost" to connect to port 80 of the apache server.
I am able to successfully connect to the server and open a read and write stream via the iPhone, but I am not sure how to send data to the iphone using PHP running from the LAMP server to the iPhone.
I think I can use fsockopen in php to open a socket connection and write data to that socket. I tired running this code
$fp = fsockopen("tcp://localhost", 80, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
echo"writing to socket
";
fwrite($fp, "wwqeqweqw eqwe qwe \n");
//echo fread($fp, 26);
fclose($fp);
echo "done";
}
But, I dont see anything being read on the iphone.. Any idea what's going on, or how to accomplish this?
Thanks!