views:

44

answers:

1

Hi,
What's an example of a simple handshake between a php socket server and flash? A test I can run command line would be ideal, since I don't have a server for this experiment.

I'm need a good example that's easy, and something I can run off my laptop without internet:)
Thanks

FLASH CLIENT

//SOCKET CLIENT IN FLASH AS3
var xmlSoc=new XMLSocket();
xmlSoc.addEventListener(Event.CONNECT, socEventCatch);
xmlSoc.connect("localhost", 1999);
xmlSoc.addEventListener(Event.CLOSE, socEventCatch);
xmlSoc.addEventListener(IOErrorEvent.IO_ERROR, socEventCatch);
xmlSoc.addEventListener(DataEvent.DATA, socEventCatch);
function socEventCatch(Event):void{
trace("Received Data: " + Event.data);
var xml_msg:XML = new XML(Event.data);
//STRING TEST 'HELLO WORLD'
var MYSTRING:*;
MYSTRING =xml_msg.body.MYSTRING;
txt.text = String(MYSTRING);
}

XML MESSAGE 'Hello World'

<msg>
  <body>
    <MYSTRING>#3: HELLO WORLD</MYSTRING>
  </body>
</msg>

PHP SOCKET AND POLICY FILE?

A: 

java is much more suitable for a socket server. check this basic example which includes source code.

maxmc