Category: Flex

Flex socket sucks

ActionScript
Image via Wikipedia

We needed to build a Flex based FTP upload client. With socket support and the help of ActionScript 3 this should be pretty easy.

However I was very surprised to see that this was not at all easy. Flushing data from the socket is non-blocking. This means that you send the data and don’t get any feedback when the data is done.

The FileStream class however seems to have solved this with OutputProgressEvent. Why not Sockets?

So to build our FTP client we needed to split the data and send it chunk by chunk and loop through it. This is a really bad solution as we need to be absolutely sure that the previous chunk is done before sending the next. This means that that any upload will be extremely slow.

If you read this and feel you have a workaround please share.

BTW: This behavior is reported as a bug at Adobe (read more)

Reblog this post [with Zemanta]