I was just doing some testing using PHP sockets and Flash. I used several things, one thing is this tutorial: http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm . I have the server running, and when I run the swf via Flash it connects fine. But when I run it from the browser it can’t connect… Because that Tutorial is in AS2, I also wrote a quick client to connect with AS3, but I’m having the exact same problem… it only connects if I run it through flash.
Here’s an example of the basic code:
var s:Socket = new Socket('my IP', 5445);
s.addEventListener(ProgressEvent.SOCKET_DATA, getData);
function getData(e:ProgressEvent):void
{
var d:String = s.readUTFBytes(s.bytesAvailable);
serverResponse.text = d;
}
s.writeUTFBytes("Hello
");
s.flush();
This is just for testing… but again it should return the server’s response and put it inside “serverResponse” (dynamic text field), but it only works when I run it through flash.