Creating a simple communication protocol

Having covered all of the basics, we're finally ready to get designing! The first choice we need to make is which protocol suits our needs better. Losing packets in a real-time application like this is not a tragedy. It's more important that data is sent and received as quickly as possible in order to update the player and all of the entities in the game. Since TCP is a slower protocol and we would not benefit from the extra measures it takes to deliver data in order, the choice is clear. User datagram protocol is the way to go.

Let's flesh out some details of the system we're going to be building by first defining some packet types that are going to be exchanged between the server and client, as well as ...

Get SFML Game Development By Example 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.