Transferring files using javascript via websockets

Hi, I am trying to transfer files. I have some programs that convert files to binary files and transfer them over the network using C ++. I was wondering if I can transfer files using javascripts and websockets? any examples of how to integrate my C ++ program into javascript would be appreciated. thank.

+5
source share
2 answers

Javascript has two new binary types: typed arrays (arraybuffers) and Blobs (mostly files).

WebSockets supports sending and receiving typed arrays and blocks.

WebSockets ( WebSocket ).

++, , WebSocket. WebSocket : http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations

JavaScript WebSocket - :

ws = new WebSocket("ws://100.101.102.103");

send() , . , (), , ( = 2).

ws.send(myTypedArray);

, :

ws.onmessage = function (evt) {
    console.log("Got ws message: " + evt.data);
};

/, onmessage , blob binaryType. , :

ws.binaryType = "blob"; // or "arraybuffer"
+7

, , . WebSocket ; WebSocket (, ).

WebSocket , , , .

: - ?

+1

All Articles