10
It is common to find questions, answers and tutorials talking about AJAX, which is nothing more than the XMLHttpRequest
, as a form of data transfer between two computers.
I wonder if there are other ways, be they standardized or proprietary, limited in some condition or open to any user and website. An example in a limited way, if any, would be an API restricted to extensions.
In particular, but not restricting, I’m looking for a way to transfer data - somewhere between 10 and 30 bytes - as quickly as possible between two computers within the same network. Peer-to-Peer would be ideal, but I don’t know if JS supports it. I’ve tried services like Firebase, that allowed a minimum response time, however, using a server outside the network and with occasional data loss.
Knowing other ways I wanted to find one that would fit better what I’m developing. It doesn’t seem that the answer will be anything big: the options seem to be quite limited, since it seems that only AJAX is used.
Like I said seems really very limited: ajax have to use pooling or long connections, websockets is the technology firebase uses, webrtc has worse data loss problems (compared to previous).
– Gustavo Rodrigues
As you edit this answer, it develops: as Punchthenewbie said, I will end up having to use a Socket.IO server inside the network. With no other alternatives.
– Gustavo Rodrigues
If you use Socket.io, it goes as long as the browser support uses the connection you can from the websocket Protocol versions until you get to pushstream and finally flash if the browser has support. Webrtc uses UDP, which will not guarantee you package delivery, you will have to work with carousel and sumcheck to ensure deliveries.
– Gabriel Gartz
I’m leaving this question a little generic because it has at least two applications for me, one of them is slide show: I’m tired of passing the slide on a computer and not updating on others. So I worry about data loss.
– Gustavo Rodrigues
Slide synchronization is very easy and efficient with websocket, in the connection event you synchronize the client with host and then just send the status changes to replicate from one to the other. http://meteor.com is a good framework for doing this quickly and efficiently. I have a demo with checkers in http://damas.gartz.com.br but it does not make the initial sync yet, only the subsequent ones, open in 2 computers and it will replicate the actions in both by websocket.
– Gabriel Gartz
I’ve tried this with at least two different situations: two presentations for my teachers and two with my family (best beta testers I’ve ever seen). One used JSON pooling and the other websockets. Of them three failed and I had to manually control. The one that worked used Socket.IO. I’m looking for another way but it seems there’s no.
– Gustavo Rodrigues
Socket.IO uses pooling if it does not have websocket support in the browser, among other fallbacks as I explained. But the problem is not in the protocol, I think it is in the implementation that you did. Because if you guarantee status on the connection and then do message exchange there is no error. Because if error occurs, it will reconnect so it will recover the status before executing the next messages.
– Gabriel Gartz
Dr. I think your best chance is with Socket.IO. If you choose this implementation, be sure to give credit to my answer in this thread. This prevents future users from understanding that you used another alternative. Ab.
– PunchTheNewbie
What if he uses one of several alternatives to socket.io? After all this is only the best known and most buggy of the websocket libs... has the socksjs for example that is used by meteorjs and if looking will find other alternatives.
– Gabriel Gartz