开发者

Handshake between a socket server and Flash AS3

开发者 https://www.devze.com 2023-01-05 03:00 出处:网络
What\'s an example of a simple handshake between a php socket server and flash? A test I ca开发者_如何学Cn run command line would be ideal,

What's an example of a simple handshake between a php socket server and flash? A test I ca开发者_如何学Cn 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号