Class EDU.gac.max.flipserver.FlipServer
All Packages Class Hierarchy This Package Previous Next Index
Class EDU.gac.max.flipserver.FlipServer
java.lang.Object
|
+----EDU.gac.max.flipserver.FlipServer
- public class FlipServer
- extends Object
This class is the main class for a server daemon program called FlipServer
that is used by the multi-user networked puzzle program NetFlip.
Each NetFlip communicates with the FlipServer through its NetInterface.
The communication protocol is very simple: the NetInterface sends the
number of a "key" (i.e., colored button) to be flipped to the FlipServer,
which turns around and sends it back to all the NetInterfaces (including
the originating one). The only exception from this "echoing" style of
operation is that the FlipServer keeps track of the board state (which
keys are flipped) and if a new client connects, immediately sends it the
key numbers to flip so that the new client's board looks like the others.
One ClientConnectionThread is used to listen on each client's connection.
Warning: this FlipServer class is missing some "synchronized"
keywords on some methods. This is intentional as part of a lab
assignment on race conditions and monitors for the MC78 course.
The students are supposed to find the race conditions and predict
the buggy behavior that can result, then verify by inserting
appropriate sleeps, then fix the problem by adding the needed
synchronized keywords. So, this class is known to be buggy.
Written 17 Aug 1996 by
Max Hailperin
<max@gac.edu>
- See Also:
- NetFlip, NetInterface, ClientConnectionThread
-
addOut(OutputStream)
- The addOut method is used to add another output stream that should
receive the flip notifications (key numbers); this is used when
a new client connects.
-
flip(int)
- The flip method is used to record and transmit a flip; it is used
by a client connection thread that has received a flip number
-
main(String[])
-
-
removeOut(OutputStream)
- The removeOut method is used to remove one of the output streams
to which flip notifications (key numbers) are being sent; this is
used when the thread tending a particular client connection notices
that the client has closed the connection
addOut
public void addOut(OutputStream newOut)
- The addOut method is used to add another output stream that should
receive the flip notifications (key numbers); this is used when
a new client connects. Keys that were already flipped earlier are
also sent to the new stream.
removeOut
public void removeOut(OutputStream oldOut)
- The removeOut method is used to remove one of the output streams
to which flip notifications (key numbers) are being sent; this is
used when the thread tending a particular client connection notices
that the client has closed the connection
flip
public void flip(int key)
- The flip method is used to record and transmit a flip; it is used
by a client connection thread that has received a flip number
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index