3 ms·
If you're using sockets you still need to come up with some kind of protocol on top of those sockets for the data that's being transferred - message delimiter,
by simonw 1y ago
If you're using sockets you still need to come up with some kind of protocol on top of those sockets for the data that's being transferred - message delimiter, a data format etc. Then you have to build client libraries for that protocol.
WebSockets solve a bunch of those low level problems for you, in a well specified way with plenty of existing libraries.
- HumblyTossed 1y agoASCII table codes 1,2,3 & 4 pretty simple to use.
- dns_snek 1y agoSure, in principle. Someone already mentioned binary data, then you come up with a framing scheme and get to write protocol documentation, but why? What's the benefit?
- HumblyTossed 1y agoSimplicity.
- ryanjshaw 1y agoYou misspelled “bugs and maintenance nightmare”
- jcheng 1y agoNot if you're passing binary data
- woodruffw 1y agoEven beyond that: the ASCII delimiter control codes are perfectly valid UTF-8 (despite not being printable), so using them for in-band signaling is a recipe for pain on arbitrary UTF-8 data.
- mananaysiempre 1y agoIf you know your data is UTF-8, then bytes 0xFE and 0xFF are guaranteed to be free. Strictly speaking, 0xC0, 0xC1, and 0xF5 through 0xFD also are, but the two top values are free even if you are very lax and allow overlong encodings as well as codepoints up to 2³² − 1.
- woodruffw 1y agoI think it would probably be better to invest in a proper framing design than trying to poke holes in UTF-8. (This is true regardless of UTF-8 -- in-band encodings are almost always brittle!)
- tracker1 1y agoNow solve for encryption, authorization, authentication... WS(S) has in the box solutions for a lot of these... on top of that, application gateways, distribution, failover etc. You get a lot of already solved solutions in the box, so to speak. If you use raw sockets, now you have to implement all of these things yourself, and you aren't gaining much over just using WSS.
- HumblyTossed 1y ago"Now write an application that is so generic it solves every problem ever!" You don't always _need_ those things. Right? Right.
- zerd 1y agoWebSocket doesn't specify data format, it's just bytes, so they have to handle that themselves. It looks like they're using Arrow IPC. Since they're using Arrow they might look into Flight RPC [1] which is made for this use case. [1] https://arrow.apache.org/docs/format/Flight.html https://arrow.apache.org/docs/format/Flight.html