Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why no UDP connection via browser even with HTML5?

Why can we not have UDP connection between a browser and a server? Why is TCP connection possible (via WebSockets) and UDP not?

like image 441
C graphics Avatar asked Jul 15 '13 15:07

C graphics


People also ask

Can you use UDP in the browser?

UDP packets are not encrypted, so any data sent over these packets could be sniffed and read by an attacker, or even modified in transmit. It would be a massive step back for web security to create a new way for browsers to send unencrypted packets.

Can Websockets use UDP?

Websockets do not run over UDP, so this is not possible with any library anywhere. If you wan to use UDP, you'll have to use some other protocol, on both ends.

Is Websockets UDP or TCP?

The WebSocket protocol is an independent TCP-based protocol.

Is WebRTC UDP?

Not surprisingly, the architecture and the protocols powering WebRTC also determine its performance characteristics: connection setup latency, protocol overhead, and delivery semantics, to name a few. In fact, unlike all other browser communication, WebRTC transports its data over UDP.


2 Answers

HTML5 does not allow arbitrary TCP connections.

Instead, web sockets is a special new protocol built on on TCP that allows bidirectional communication.

Similarly, WebRTC is a special new protocol built on UDP that allows peer-to-peer communication.

Allowing arbitrary socket connections would be a major security hole.

like image 100
SLaks Avatar answered Nov 05 '22 18:11

SLaks


You can get access to UDP using WebRTC, which is available in the latest versions of Chrome and Firefox. This lets you do direct browser - browser connections without needing to go via the server, amongst other things.

like image 44
rjmunro Avatar answered Nov 05 '22 19:11

rjmunro