-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver_class.hpp
57 lines (48 loc) · 1.01 KB
/
server_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
#ifndef __SERVER_HPP__
#define __SERVER_HPP__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
// network related
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
using namespace std;
#define PORT 8080
#define BUFFERSIZE 1024
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];
};
struct conn_thread_args{
struct sockaddr_in cliaddr;
char message[BUFFERSIZE];
int port_num;
struct packet recvpacket;
int seq_num;
};
class server_class{
private:
struct sockaddr_in servaddr;
int welcome_sockfd;
public:
server_class();
void welcome_sock_listen();
static void* connection_sock(void*);
static struct packet create_pkt(uint32_t, uint32_t, int, char*, string);
};
#endif