Comparing UDP and ENet approaches
The UDPServer
and PacketPeerUDP
classes are lower-level networking tools that allow for the exchange of data through UDP packets. This approach requires more work from us, as we must manage the sending and receiving of packets ourselves. For example, to create a login system using UDPServer
and PacketPeerUDP
, we would need to create a packet that contains the user’s login information, send it to the server, and then wait for a response.
In Chapter 2, Sending and Receiving Data project, we saw how to use UDPServer
and PacketPeerUDP
to pass data around. We saw that using these classes, we can serialize data and deserialize it on each end of the system, both client and server. Using this approach, we need to poll packets and wait for requests and responses to arrive. It does the trick, but you saw it can get a bit complicated.
One advantage of using the UDPServer
and PacketPeerUDP
classes is that they provide more control over the networking...