Game Development Reference
In-Depth Information
Introduction
Data sent over the network is organized in packets, and protocols handle them differently.
Packets can look different depending on protocols, but they contain the data itself along
with control information, such as addresses and formatting information.
SpiderMonkey supports both TCP and UDP. In SpiderMonkey, TCP is referred to as reli-
able. TCP is reliable because it verifies each network packet sent, minimizing problems
due to packet loss and other errors. TCP guarantees that everything arrives safely (if at all
possible). Why ever use anything else then? For speed. Reliability means that TCP can be
slow. In some cases, we're not dependent on every packet reaching the destination. UDP is
more suitable for streaming and low-latency applications, but the application will have to
be prepared to compensate for the unreliability. This means that when a packet is lost in
FPS, the game needs to know what to do. Will it just stop in its tracks, or stutter along? If a
character is moving and the game can predict the movement between the messages that ar-
rive, it will create a smoother experience.
Learning how to use the API is fairly easy, but we will also see that networking is not
something you add to a game; the game needs to be adapted for it from the planning stage.
Search WWH ::




Custom Search