O'Reilly logo

SFML Blueprints by Maxime Barbier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a communication protocol

It's now time for us to create our own custom protocol. We will use an SFML class sf::Packet to transport our data, but we have to define their shapes. Let's first focus on the sf::Packet class and then on the shapes.

Using the sf::Packet class

The sf::Packet class is like a buffer that contains our data. It comes with already-made functions that allow us to serialize primitive types. I don't know if you are familiar with the internal memory storage of computers, but keep in mind that the arrangement is not the same everywhere. This is called endianness. You can see it like reading from the right or from the left. When you send data over the network, you don't know the endianness of the destination. Because of this, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required