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 36 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

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

For example, the client??™s Receive and the server??™s Send
methods handle floating point numbers (the temperature samples) rather than arrays
of bytes, as the .NET socket API does. Although these classes are more specialized
than the .NET Socket class, they still support other applications and protocols
besides the ones described here (Exercise 1).
16 Why We Need Model-Based Testing
SERVER

















Socket
Bind
Listen
Accept
Receive
Send
Close connection
Close listener
CLIENT











Socket
Connect
Send
Receive
Close



Figure 2.2. Socket API calls for client/server protocol.
Overview 17
using System;
using System.Net;
using System.Net.Sockets;
namespace ClientServerImpl
{
// Wrapper for .NET server socket
public class Server
{
Socket listenerSocket; // assigned by Socket
Socket connectionSocket; // assigned by Accept, used by Send etc.
const int BUFLEN = 40;
byte[] receiveBuf = new byte[BUFLEN];
// method Client.Socket assigns instance of System.Net.Sockets.Socket
public void Socket()
{
listenerSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
}
public void Bind(string ipAddr, int port)
{
listenerSocket.Bind(new IPEndPoint(IPAddress.Parse(ipAddr), port));
}
public void Listen()
{
const int backlog = 0;
listenerSocket.


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