How to send binary data from a Node.js socket.io server to a browser client?

前端 未结 2 2018
攒了一身酷
攒了一身酷 2020-12-14 18:30

I\'ve been looking through the entire Socket.IO docs, but, even though they promise it is there, I can\'t find a simple, minimal example, of how one would send binary data b

2条回答
  •  渐次进展
    2020-12-14 19:19

    Starting from socket.io 1.0 it is possible to send binary data. http://socket.io/blog/introducing-socket-io-1-0/

    How ever the way of sending and receiving binary data is not clear in the official documentation. The only documentation is:

    var socket = new WebSocket('ws://localhost');
    socket.binaryType = 'arraybuffer';
    socket.send(new ArrayBuffer);
    

    I suggest you to take a look at this answer, where you can find basic example with code implementation for server and client (javascript and java too):

    How to send binary data with socket.io?

    The good part is that it also works on Android! (if you wish)

    Cheers

提交回复
热议问题