Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SFML Blueprints

You're reading from   SFML Blueprints Sharpen your game development skills and improve your C++ and SFML knowledge with five exciting projects

Arrow left icon
Product type Paperback
Published in May 2015
Publisher Packt
ISBN-13 9781784398477
Length 298 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

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, the convention is to send data as a big-endian arrangement over the network. I suggest you to take a look at the Wikipedia page (https://en.wikipedia.org/wiki/Endianness) for more details.

Thanks to SFML, there are some pre-existing functions that...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime