-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_class.hpp
58 lines (51 loc) · 1.12 KB
/
client_class.hpp
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
58
# ifndef __CLIENT_HPP__
# define __CLIENT_HPP__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
// network related
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
using namespace std;
struct header{
uint16_t src_port;
uint16_t des_port;
uint32_t seq_num;
uint32_t ack_num;
uint8_t len;
uint8_t flags;
uint16_t rwnd;
uint16_t checksum;
uint16_t urgent;
};
struct packet{
struct header myheader;
char message[1024];
};
class client_class{
private:
int sockfd, seq_num, ack_num, rwnd, port_num, mss, rcv_base;
struct sockaddr_in servaddr;
string ip_address;
vector<string> message_vector;
queue<struct packet> message_queue;
vector<pair<int, bool>> client_wnd;
struct timeval timeout;
vector<struct packet> packet_buffer;
public:
client_class();
void send_pkt(struct packet);
struct packet recv_pkt();
void set_pkt();
struct packet create_pkt(string, string);
void* processing(void*);
int est_connection();
void set_request(string);
void write_file(ofstream &fp);
};
#endif