SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 37 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

"Model-Based Software Testing and Analysis with C#"

Listen(backlog);
}
// Socket.Accept returns connectionSocket used by Send, Receive, etc.
public void Accept()
{
connectionSocket = listenerSocket.Accept();
}
// to be continued ...
Figure 2.3. Remote instrument server class (1).
We will now briefly describe how to build libraries in the .NET framework.
We put each class, Client and Server, in its own file, Client.cs and Server.cs,
respectively. This is a common convention but it is not required. This command
invokes the C# compiler csc to compile the client library.
csc /target:library Client.cs
18 Why We Need Model-Based Testing
// ... continued
public string Receive()
{
int nbytes = connectionSocket.Receive(receiveBuf);
string command =
System.Text.Encoding.ASCII.GetString(receiveBuf,0,nbytes);
return command; // command.Length = 0 means connection closed
}
public void Send(double datum)
{
string response = String.Format("{0:F1}", datum); //1 decimal digit
byte [] sendBuf = System.Text.Encoding.ASCII.GetBytes(response);
connectionSocket.Send(sendBuf);
}
public void CloseConnection()
{
connectionSocket.Close();
}
public void Close()
{
listenerSocket.Close();
}
}
}
Figure 2.4. Remote instrument server class (2).
In the .NET framework, a collection of code that is compiled together (in one csc
command) is called a source program. In this simple example, the source program
is a single class in a single file.


Pages:
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6