top | item 28277342

(no title)

sobakistodor | 4 years 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".

discuss

order

Jtsummers|4 years ago

> 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.

eitland|4 years ago

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 :-)

selfhoster11|4 years ago

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.

southerntofu|4 years ago

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.

ajconway|4 years ago

Bytes don't care about protocols, but anyone who cares about future and backwards compatibility should.

lelanthran|4 years ago

serializer fixes endianess?