Does flash actionscript allow you to contact an arbitrary server on a specific port?
I would like to stream some images live from a server using a propr开发者_开发百科ietary protocol.
Or does the browser disallow this for security reasons?
you can use the Socket (flash.net.Socket) class or XMLSocket (flash.net.XMLSocket) class, though the XMLSocket class is limited to ports higher than 1024.
Usually you will have to provide flash with a policy document before it can connect to the port you want. This file can be provided by a policy server:
http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
I would also recommend reviewing the Flash Player security model:
http://www.adobe.com/devnet/flashplayer/security.html
I would suggest exploring AMF (http://en.wikipedia.org/wiki/Action_Message_Format) if you want to start writing socket servers for Flash. It is a nice convenient protocol for exchanging communications with Flash.
I use the python library twisted (http://twistedmatrix.com/trac/) to write socket servers and policy servers usually. PyAMF is also worth looking at (http://pyamf.org/). There are also a number of AMF servers and libraries for other langauges.
精彩评论