Networking: Game2D Code Study
Tom Kelliher, CS 245
Oct. 7, 2002
Deliverables on Wednesday. Exam on Friday.
None.
Threads and Synchronization.
- Hints for developing network code.
- Game2D code study.
Networking Lab.
- Currently, network applets must be run from inside the firewall.
Requesting firewall access for a block of ports on black.
- Sun's AppletViewer's implementation of the Socket library leaves much
to be desired. And you have to use the policytool to seriously weaken
Java's security model.
What you'll need to do: Serve your applet from (soon to be installed) Apache
on black. Java's security model permits an applet to connect back to the
server which served it.
It may be easier to do you client development on black.
- If you re-compile your applet for serving from a web server, you must
exit and re-start your browser so that it loads fresh versions of the class
files.
Why I'm not putting the source code on the class web page.
Work in your teams to answer the following:
-
Game2Dclient.java
questions:
- Each client runs two threads. What are they?
- Once the game has begun, what action or actions cause the applet
class (line 8) to send a message to the server? What is the format of
those messages?
- Where in the applet class code is the connection to the server
made?
- The listen class (line 130) only receives messages from the
server. What kinds of messages does it receive? Does it act on those
messages directly or indirectly (through a synchronized queue or some
other such mechanism.).
-
G2DLaunch.java
questions:
- Why is the main class so short (lines 276--282)?
- Looking at line 20, explain what the Timer does and how it does
it. It may be helpful to have a look at lines 202--204.
- Explain how the G2DServer class (line 5) design permits multiple
games to occur simultaneously.
- Three server threads are required per game. What are they?
- What are the main responsibilities of the Game2D class (line 56)?
- In line 43, why is the server connecting to itself? Isn't that
illegal in Maryland?
- Do the ThreadedEchoHandlers (line 137) communicate directly with
the two clients or indirectly (using another thread or each other as
agents)?
- Why is the sky blue?
- General question: Where are potential synchronization problems?
Thomas P. Kelliher
Sun Oct 6 22:20:42 EDT 2002
Tom Kelliher