Hardware Reference
In-Depth Information
Conclusion
The basic structure of the clients and server in this chapter can be used any time
you want to make a system that manages synchronous connections between several
objects on the network. The server's main jobs are to listen for new clients, keep track
of the existing clients, and make sure that the right messages reach the right clients. It
must place a priority on listening at all times.
The client should also place a priority on listening, but
it has to juggle listening to the server with listening to
the physical inputs. It should always give a clear and
immediate response to local input, and it should indicate
the state of the network connection at all times.
Finally, make sure you've got a reliable way to test the
system. Simple tools like a telnet client and test server will
save you much time in building every multiplayer server,
and help you get to the fun sooner.
Now you've seen examples of both asynchronous client-
server exchanges (the HTTP system in Chapter 4) and
synchronous exchanges (the chat server on page 153). With
those two tools, you can build almost any application in
which there's a central server and a number of clients. For
the next chapter, you'll step away from the Internet and
take a look at various forms of wireless communication.
X
The protocol that the objects in this system speak to each
other should be as simple and as flexible as possible.
Leave room for more commands, because you never
know when you might decide to add something. Make
sure to build in responses where appropriate, like the “hi”
and “bye” responses from the server. Keep the messages
unambiguous and, if possible, keep them short as well.
At left
Jin-Yo Mok's original
sketches of the music
box.
At right
The music box composi-
tion interface.
 
Search WWH ::




Custom Search