We’ve been looking into some inconsistent behaviour across platforms when making socket connections. An application that works fine in Windows and OSX fails for no apparent reason when running on Linux platforms. After running a WireShark network capture, we established that, after correctly fetching a socket policy from port 843 of the remote host, the data sent to the target port was corrupted when using Linux Flash Player.
It turns out that the culprit is the Linux implementation of
Socket.writeMultiByte, at least certainly when using the “us-ascii” encoding (it’s late and we can’t be bothered to test other encodings).
So, the line:
socket.writeMultiByte("GET somepath HTTP/1.0 \r\n","us-ascii");
fails completely, with garbage getting written to the socket.
We’ve written a naive (and appropriately named) replacement which works for what we’re doing, but doesn’t handle encodings.
private function writeBetterMultiByte2(msg:String):void
It appears that we’re not the only ones having trouble with writeMultiByte, but this time it’s with
ByteArray.writeMultiByte . Something seems quite broken here.