# Binary Socket

**URL:** <https://forum.kirupa.com/t/binary-socket/283587>\
**Category:** flash\
**Created:** [March 8, 2009, 6:29pm UTC](https://forum.kirupa.com/t/binary-socket/283587 "2009-03-08T18:29:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PsuFan](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@PsuFan](https://forum.kirupa.com/u/PsuFan)\
**Post date:** [March 8, 2009, 6:29pm UTC](https://forum.kirupa.com/t/binary-socket/283587/1 "2009-03-08T18:29:14Z")

</div>

Hello,

Everyone claims that they have a binary socket using the Socket() class but I havent found any that work properly.

I have tried var sData = socket.readUTFBytes(sock.bytesAvailable); which works fine for plain text, but when you send it binary it doesnt work. (sData.length = 0)

I have also tried socket.readBytes(sReceive, 0, socket.bytesAvailable); and then convertered to a string. I thought this method was working but it turns out its not because a Byte in AS3 = -128 to 127. So when you encode a binary character (From 0 to 255) AS3 displays garbage when it gets a value higher then 127. Since the server cant encode binary from -128 to 127 because its ASCII. Has anyone run into this?

Thanks
