When using dgram (UDP) with Socket.IO, at what speed are datagrams sent? (node)

I am using socket.io and the dgram node library to send UDP messages from one program to the browser via node.
The code looks just like 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); }); }); 

Question: at what speed are datagrams sent to the browser? They are sent at TCP speed, web socket speed (which I understand more slowly) or UDP speed (which I understand faster when it comes to real-time transmission).

Also, in this example, io is constantly listening on port 80 (which means that it can only receive data at HTTP / tcp speeds) or it just listens for a socket connection and then can stop listening (and allow the socket connection more)

+6
source share
1 answer

UDP, TCP, and WebSockets packet rates are the same (for example, baud rate), but they differ in overhead and reliability.

  • WebSockets is a tunnel in an existing HTTP connection, so TCP action has more overhead. But they use existing tunneling methods through a NAT router and firewalls.
  • TCP has guarantees of reliability, for example. no packets are lost or duplicated. TCP requires an initial three-way handshake, but this is only one time for connection, and not for each data block.
  • UDP is fire and forget it and you need to implement your own reliability from above if you need it. Also, I'm not sure if the browser will even accept your UDP packet initially, at least outside the RTP context (e.g. WebRTC). It can work with Java and Flash.
+4
source

All Articles