Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

socket.io streaming binary data

I have just started using node.js, I'm running a node server with sockets.io and i need to send a buffer of bytes to the client.

I understand that this can be done by first translating the byte buffer to base64 and sending that, then translating it back on the client side. but i was wondering if there is a more elegant way of getting the byte stream to the client.

like image 709
crimsonsky2005 Avatar asked Sep 01 '12 13:09

crimsonsky2005


2 Answers

Socket.IO 1.0 Now supports Binary data transfer. Please have a look here . You can use Blob, ArrayBuffer and File.

like image 70
Gaurav Ramanan Avatar answered Oct 06 '22 19:10

Gaurav Ramanan


https://github.com/binaryjs/binaryjs can be a solution. base 64 have ~30% of overhead size, so if you need to transfer large amount of data it will become inefficient.

like image 40
Yury Solovyov Avatar answered Oct 06 '22 20:10

Yury Solovyov