[Twisted-Python] Transfering a file through ActionScript xml sockets

Phil Christensen phil at bubblehouse.org
Wed Nov 28 16:13:00 EST 2007

On Nov 27, 2007, at 11:50 PM, Raj kumar wrote:
> Sorry for not giving clear information in my previous mail.
> I am using action script xml sockets.
> Now anyone can help me in transferring a file to client using action  
> script xml sockets.
> Thank you in advance.

Despite the name, ActionScript's XMLSockets work just fine as regular  
sockets. If you send XML through them, and it happens to be well- 
formed, it will trigger the XML-specific event handler (i think it's  
onXML), but you can also just use the onData handler instead.

  var buffer = '';
  socket.onData = function(chunk){
	buffer += chunk;

The data will be coming in chunks, so you'll need to buffer it in some  
way until you get the whole file.

Obviously, Flash won't let you save this file, so I'm assuming it's  
some kind of datafile your app needs to parse. If that's the case,  
your life will be easier if you just use loadVars to retrieve a  
urlencoded datafile, which will be parsed and returned to you as an  
anonymous object. I don't have any snippets for this process, but  
loadVars() is a commonly used function, and there's good docs in  
internal Flash Help and on the adobe site.

If either HTTP or custom datafiles won't work for you because of  
various requirements, you're pretty much going to have to write your  
own protocol. This is easy on the Twisted side of things, but  
extremely irritating on the actionscript side, IMO. How you go about  
this has more to do with the requirements of your current application,  


More information about the Twisted-Python mailing list