Network.h

480 views
428 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
480
On SlideShare
0
From Embeds
0
Number of Embeds
135
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Network.h

  1. 1. Network.h
  2. 2. #ifndef NETWORK_H#define NETWORK_H#include "copyright.h"#include "utility.h“When using ifndef conditional we mean the specialist tosee if a macro identifier is defined or not.
  3. 3. class Network { public: Network(NetworkAddress addr, double reliability, VoidFunctionPtr readAvail, VoidFunctionPtrwriteDone, int callArg);~Network(); // De-allocate the network driverdata void Send(PacketHeader hdr, char* data); PacketHeader Receive(char* data); void SendDone(); void CheckPktAvail();
  4. 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 cango out on the wire.#define MaxPacketSize
  5. 5. private: NetworkAddress ident; // This machines networkaddress double chanceToWork; // Likelihood packet will bedropped int sock; // UNIX socket number for incomingpackets char sockName[32]; VoidFunctionPtr writeHandler; VoidFunctionPtr readHandler;
  6. 6. int handlerArg; // Argument to be passed tointerrupt handler bool sendBusy; bool packetAvail;// network PacketHeader inHdr;char inbox[MaxPacketSize];};#endif

×