views:

101

answers:

1

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 proprietary protocol.

Or does the browser disallow this for security reasons?

+5  A: 

Hi, 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%5Fpolicy%5Ffiles.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%5FMessage%5FFormat) 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.

Jotham