-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotocolUtil.h
57 lines (53 loc) · 1.23 KB
/
protocolUtil.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
49
50
51
52
53
54
55
56
57
struct game_prtcl{
uint8_t version;
uint8_t pos;
uint8_t state;
uint8_t dscrpt;
uint8_t gametype;
uint8_t gamenum;
uint8_t seqNum;
uint8_t pos1;
uint8_t pos2;
uint8_t pos3;
uint8_t pos4;
uint8_t pos5;
uint8_t pos6;
uint8_t pos7;
uint8_t pos8;
uint8_t pos9;
};
struct mltcst_send_prtcl{
uint8_t version;
uint8_t command;
};
struct mltcst_recv_prtcl{
uint8_t version;
uint8_t command;
// network order
uint16_t port;
};
extern int VERSION;
extern int TIMEOUT;
extern int NEWGAME;
extern int MOVE;
extern int END;
extern int RECONNECT;
extern int GAMECONTINUED;
extern int COMPLETE;
extern int GAMEERROR;
extern int NORESOURCE;
extern int MALFORM;
extern int CLIENTTIMEOUT;
extern int TRYAGAIN;
extern int DRAW;
extern int CLIENTWIN;
extern int SERVERWIN;
extern int ASKADDR;
extern int GIVEADDR;
void importBoard(struct game_prtcl *protocol, char board[3][3]);
void exportBoard(char board[3][3], struct game_prtcl * protocol);
int readMoveTCP(int sd, struct game_prtcl *protocol);
int sendErrorTCP(int sd, struct game_prtcl *protocol, int err_dscrpt);
int sendMoveTCP(int sd, struct game_prtcl *protocol);
int getNumFromStr(char *s, uint32_t *num);
int setTimeoutSD(char argv, int second);