-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode.h
48 lines (39 loc) · 755 Bytes
/
node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
#ifndef NODE_H
#define NODE_H
#include "csapp.h"
#include <unistd.h>
class NodeInfo{
public:
char IP[20];
char port[10];
NodeInfo(const char *, const char *);
NodeInfo();
};
class TimerProcess{
public:
virtual void invoke()=0;
};
class Node{
protected:
TimerProcess * timerProcess;
void timerStart();
public:
NodeInfo myInfo;
Node(const char* port, const char * ip);
virtual void run();
virtual void processRequest(rio_t & , int)=0;
void sendNodeInfo(int fd);
NodeInfo readNodeInfo(rio_t & r);
static int connectTo(NodeInfo & n);
~Node();
};
struct Arg {
int connfd;
Node * n;
int myPort;
char myIP[20];
} ;
void * receiveRequest(void * );
void * listenThread(void * );
void * heartBeat(void *);
#endif