We use a comment to
indicate the expected return value of ClientReceive in this trace. We explain how
return values are handled in the NModel framework in Chapter 8, Section 8.2.
State variables
In the implementation, there are classes for the client and server, and particular
clients and servers are instances. Any program with instances is potentially ???infinite,???
because it can create an unlimited number of them.We must make our model program
finite. In our tests, we will only have one client and one server, so instances are not
needed. In our model program, the state variables are the static variables needed to
model just one client and one server. This is an example of data abstraction. A model
program where all variables are static can model an implementation with instances
and can be connected in a test harness with that implementation (Chapter 8).
Recall that state variables can store control state that determines the sequence
of actions. In this example, there are two kinds of constraints on that sequence.
Sockets must be created, connected, and closed according to the protocol shown
in Chapter 2, Figure 2.2. And, the send and receive actions must alternate, always
beginning with a send action. Therefore we have three state variables for the control
state. Two keep track of each partner??™s step in the protocol: clientSocket and
serverSocket.
Pages:
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121