Hacker News new | ask | show | jobs
by sobakistodor 1756 days ago
We develop Web in C++ and all our protocols looks like this:

  serializer.put<uint32_t>(item).put(another).put(this);
  if (writer.valid()) {
    // no overflows or other problems
    socketwriter.write(serializer.data());
  }
Simple. Bytes. Dont care about any "protocols".
5 comments

> Simple. Bytes. Dont care about any "protocols".

You have a protocol there, you have an understanding of what's expected on either side of that communication. That is the definition of a protocol. And if that's for Web stuffs, as you say, then you must be implementing something related to HTTP/HTTPS, protocols.

A company I used to work for used to do something like this (I never had access to the source code, but I inspected it closely with Wireshark a time or two).

Sent over UDP this had stood the test of time for a couple decades or so.

Disadvantage: the rest of the system was also written in C++ and it was impossible to get those who had access to the source code and knew it to fix anything. As a result the system looked more and more antiquated and there were more and more hoops to jump through to get it working with every new version of Windows:-/

Edit: that said, I think your comment is a bit off topic :-)

Good luck with upgrading or downgrading anything. There's a reason why people serialise to well-known formats like protobuf and JSON, and it's because they are extensible.
Moreover, there's a reason why people standardize/specify their profobuf/JSON/XML schemas, and it's because that's more extensible than unversioned, unnamespaced serialized data.
Bytes don't care about protocols, but anyone who cares about future and backwards compatibility should.
serializer fixes endianess?