-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresponse.h
50 lines (40 loc) · 1.21 KB
/
response.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
#ifndef RESPONSE_H
#define RESPONSE_H
#include "request.h"
#include "worker.h"
//Error codes
#define NO_ERROR ((char) 0x0000)
#define KEY_NOT_FOUND ((char) 0x0001)
#define KEY_EXISTS ((char) 0x0002)
#define VALUE_TOO_LARGE ((char) 0x0003)
#define INVALID_ARGUMENT ((char) 0x0004)
#define ITEM_NOT_STORED ((char) 0x0005)
#define INC_DCR_NON_NUM ((char) 0x0006)
#define UNKNOWN_COMMAND ((char) 0x0081)
#define OUT_OF_MEMORY ((char) 0x0082)
struct response_header {
char magic;
char opcode;
char key_length[2];
char extras_length;
char data_type;
char status[2];
char total_body_length[4];
uint32_t opaque;
char CAS[8];
};
struct udp_response_header{
struct udp_header* udp_header;
struct response_header response_header;
};
struct response {
struct request* request;
struct response_header response_header;
int value_size;
};
void receiveResponse(struct request* request, double difftime);
int udpReceiveResponse(struct request* request, int final, double difftime);
int tcpReceiveResponse(struct request* request, int final, double difftime);
int processResponse(struct response* response, int final, double difftime);
void checkError(int errorCode, char* key, char* value);
#endif