Data transport

We already know some things about how sockets behave and their inner workings, but we only talked about sending and receiving data in an abstract way. We referred to the data as arrays of bytes, which we simply send and receive, but how is it done?

Indeed, what is passed on through the network is merely a block of data, a collection of raw bytes. Therefore, it must be sent in a way that can be read again by the remote machine. Your data could be anything, text, numbers, images, sound, or pretty much anything that is digital.

For this, we pack and unpack our data into a byte array when sending/receiving it! When we use the term packet, we refer to a collection of bytes, which contain one or more primitives (integers, floats, and others). ...

Get SFML Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.