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). This is very efficient from the perspective that we don't have additional overhead for sending multiple primitives; they all go at once in the same byte array. However, we have a per-packet overhead, namely the packet headers that are required...