5). The
structure of this model program, like all model programs, is similar to the first one
(Section 5.4, Figures 5.4 and 5.5). The following paragraphs explain some features
that might not be obvious.
Unlike the implementation, here the client and server are not instances. The state
of both client and server are static variables in one static class, and the actions of both
are static methods in this class. Therefore, we use a C# static class. The compiler
checks that all the variables and methods in a static class are declared static.
There are different methods for the actions of the client and the server, with
different names. The ClientSocket and ServerSocket action methods here model
the Socket methods of the client and server classes in the implementation, and so
on. All of the action methods in a model (in the model namespace) must have
different names. It is possible to have more than one class in a model, but even then
76 Model Programs
using NModel;
using NModel.Attributes;
using NModel.Execution;
namespace ClientServer
{
public enum Socket { None, Created, Bound, Listening, Connecting,
Connected, Disconnected, Closed }
public enum Phase { Send, ServerReceive, ClientReceive }
public static class ClientServer
{
const double EmptyBuffer = double.MaxValue;
const double Temp2 = 99.9; // Temperature, 2 digits
const double Temp3 = 100.
Pages:
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124