Game Development Reference
In-Depth Information
Constructing a packet
The main concept of the packet is this: fill it up with data, send it over, and read all the data
from the packet on the other end. It will seem like the exact same packet has been received
on the other end.
The Packet class is built with a streaming interface, so we can use the '<<' operator to
write to it and the '>>' operator to read it:
On the receiving end we can get those values back by doing the following:
We can also write operator overloads for custom data types. For example, SFML doesn't
provide a read/write operator for the Vector2f ( Vector2<float> ) class. We can use
our own implementation in this case:
Search WWH ::

Custom Search