3 ms·
Minor correction: you can use UDP, or at least networking with UDP-like characteristics (unreliable, packet based, low latency). This is because there is a Web
by IshKebab 11y ago
Minor correction: you can use UDP, or at least networking with UDP-like characteristics (unreliable, packet based, low latency).
This is because there is a WebRTC data channel you can use that uses SCTP. Emscripten emulates UDP on top of SCTP (which should be just a few bytes overhead per packet). Emscripten also includes the excellent enet networking library which let's you multiplex multiple reliable and unreliable channels on the same connection.
It's kind of a crazy multi-level hack (enet->UDP->SCTP->UDP->C++->JavaScript) but it works well.
- Matthias247 11y agoBut this would require the remote peer to utilize the same protocol encapsulation (UDP->SCTP->UDP), wouldn't it? This means due to browser limitations you can never directly speek an existing UDP/TCP protocol besides HTTP/WS.
- IshKebab 11y agoYes that's true. I think it is not too much of a limitation though. The major use of UDP is games and if you're writing a game you control the whole protocol anyway.