___ ___ erkimt What are the data transfer forms available to JavaScript? ______ qstntxt ___

It is common to find questions, answers and tutorials talking about AJAX, which is nothing more than %code% , as a way of transferring data between two computers.

I would like to know if there are other forms , whether standard or proprietary, limited in some condition or open to any user and site. An example of a limited form, if any, would be an API restricted to extensions.

In particular, but not restricting, I'm looking for a way to transfer data - something between 10 and 30 bytes - in the fastest way possible between two computers within the same network. Peer-to-Peer would be ideal, but I do not know if JS supports it. I have already tried testing services such as Firebase , which allowed a minimum response time, however, using a server out of network and with occasional loss of data.

Knowing other ways I wanted to find one that would fit better with what I'm developing. It does not look like the answer will be anything big: the options seem to be quite limited, since it looks like only AJAX is used.

    
______ azszpr8188 ___

There are several APIs that will allow you to transport data via Javascript.

Some will only allow you to receive data, others will allow you to send and receive.

The ones that allow you to send and receive data are:

  • %code%
    • Requests via HTTP protocol
  • %code%
    • It is a cross-compatible HTTP protocol focused on message exchanges lighter and faster than request, but it does not have a state resolution as efficient as %code%
    • W3C Specification
  • %code%
    • Peer-to-peer data exchange protocol was created to solve the problem of video and audio transmissions between browsers.
    • W3C Specification

If the data transmission needs to be p2p, the ideal is to use WebRTC, but it is still rather complex to create a server that will make the handshake between two browsers and start communication.

A simpler solution is to use WebSockets , but all information will go through a server that will receive data from one client and send it to another or other clients. But the websocket has the constraint of working with UTF-8, however it is possible to use data converters to convert binary data to UTF-8 before being transmitted and back to the original format when received, there are several ways, one of them is using the %code% .

    
______ azszpr8194 ___

I suggest using Socket IO, a javascript extension already adapted for use in cross-browser and that has an extra advantage, it chooses the most efficient way to carry data between the technologies below (which are the answer to your question) :

1) WebSocket;
2) Adobe Flash Socket;
3) AJAX long polling;
4) AJAX multipart streaming;
5) Forever iframe;
6) JSONP Polling.

Still, this extension has excellent compatibility: IE 5.5+; Safari 3+; Chrome 4+; Firefox 3+; Opera 10.61+; Iphone / Ipad Safari; Android Webkit and Webkits Webkit.

link

I have had excellent experiences with this extension. When you opt for a path where fallbacks are already included, everything gets easier!

Good Luck!

    
___

10

It is common to find questions, answers and tutorials talking about AJAX, which is nothing more than XMLHttpRequest , as a way of transferring data between two computers.

I would like to know if there are other forms , whether standard or proprietary, limited in some condition or open to any user and site. An example of a limited form, if any, would be an API restricted to extensions.

In particular, but not restricting, I'm looking for a way to transfer data - something between 10 and 30 bytes - in the fastest way possible between two computers within the same network. Peer-to-Peer would be ideal, but I do not know if JS supports it. I have already tried testing services such as Firebase , which allowed a minimum response time, however, using a server out of network and with occasional loss of data.

Knowing other ways I wanted to find one that would fit better with what I'm developing. It does not look like the answer will be anything big: the options seem to be quite limited, since it looks like only AJAX is used.

    
asked by anonymous 06.03.2014 / 01:30

2 answers

11

There are several APIs that will allow you to transport data via Javascript.

Some will only allow you to receive data, others will allow you to send and receive.

The ones that allow you to send and receive data are:

  • XMLHttpRequest
    • Requests via HTTP protocol
  • WebSocket
    • It is a cross-compatible HTTP protocol focused on message exchanges lighter and faster than request, but it does not have a state resolution as efficient as XMLHttpRequest
    • W3C Specification
  • WebRTC
    • Peer-to-peer data exchange protocol was created to solve the problem of video and audio transmissions between browsers.
    • W3C Specification

If the data transmission needs to be p2p, the ideal is to use WebRTC, but it is still rather complex to create a server that will make the handshake between two browsers and start communication.

A simpler solution is to use WebSockets , but all information will go through a server that will receive data from one client and send it to another or other clients. But the websocket has the constraint of working with UTF-8, however it is possible to use data converters to convert binary data to UTF-8 before being transmitted and back to the original format when received, there are several ways, one of them is using the Uint8Array .

    
06.03.2014 / 01:39
7

I suggest using Socket IO, a javascript extension already adapted for use in cross-browser and that has an extra advantage, it chooses the most efficient way to carry data between the technologies below (which are the answer to your question) :

1) WebSocket;
2) Adobe Flash Socket;
3) AJAX long polling;
4) AJAX multipart streaming;
5) Forever iframe;
6) JSONP Polling.

Still, this extension has excellent compatibility: IE 5.5+; Safari 3+; Chrome 4+; Firefox 3+; Opera 10.61+; Iphone / Ipad Safari; Android Webkit and Webkits Webkit.

link

I have had excellent experiences with this extension. When you opt for a path where fallbacks are already included, everything gets easier!

Good Luck!

    
06.03.2014 / 01:54