I am using socket.io and the dgram node library to send UDP messages from one program to a browser via node.
The code looks just like the socket.io example
var dgram = require("dgram");
var dServer = dgram.createSocket("udp4");
dServer.bind(12345, '0.0.0.0');
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
dServer.on("message", function (msg) {
socket.send('message', msg);
});
});
My question is at what speed are the datagrams ultimately being sent to the browser? Are they being sent at TCP speeds, web socket speeds (which I understand to be slower) or UDP speeds (which I understand are quicker when it comes to real time communication).
Also, in this example is io perpetually listening on port 80 (meaning it can only receive things at http / tcp speeds) or does it just listen to establish the socket connection and then can stop listening (and let the socket connection take over)
The speed of UDP, TCP and WebSockets "Packets" are the same (e.g. wire speed), but they differ in overhead and reliability.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With