Why can we not have UDP connection between a browser and a server? Why is TCP connection possible (via WebSockets) and UDP not?
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.
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.
The WebSocket protocol is an independent TCP-based protocol.
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.
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.
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.
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