2. #ifndef NETWORK_H
#define NETWORK_H
#include "copyright.h"
#include "utility.h“
When using ifndef conditional we mean the specialist to
see if a macro identifier is defined or not.
3. class Network {
public:
Network(NetworkAddress addr, double reliability,
VoidFunctionPtr readAvail, VoidFunctionPtr
writeDone, int callArg);
~Network(); // De-allocate the network driver
data
void Send(PacketHeader hdr, char* data);
PacketHeader Receive(char* data);
void SendDone();
void CheckPktAvail();
4. typedef int NetworkAddress;
class PacketHeader {
public:
NetworkAddress to; // Destination machine ID
NetworkAddress from; // source machine ID
unsigned length; // bytes of packet data
};
#define MaxWireSize 64 // largest packet that can
go out on the wire.
#define MaxPacketSize
5. private:
NetworkAddress ident; // This machine's network
address
double chanceToWork; // Likelihood packet will be
dropped
int sock; // UNIX socket number for incoming
packets
char sockName[32];
VoidFunctionPtr writeHandler;
VoidFunctionPtr readHandler;
6. int handlerArg; // Argument to be passed to
interrupt handler
bool sendBusy;
bool packetAvail;
// network
PacketHeader inHdr;
char inbox[MaxPacketSize];
};
#endif