-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn.h
38 lines (31 loc) · 961 Bytes
/
conn.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
#ifndef CONN_H
#define CONN_H
#include <arpa/inet.h>
#include "fdwrapper.h"
class conn
{
public:
conn();
~conn();
void init_clt( int sockfd, const sockaddr_in& client_addr );
void init_srv( int sockfd, const sockaddr_in& server_addr );
void reset();
RET_CODE read_clt(); //客户端读事件处理
RET_CODE write_clt();
RET_CODE read_srv(); //服务器读事件处理
RET_CODE write_srv();
public:
static const int BUF_SIZE = 2048; //统一缓冲区大小
char* m_clt_buf; //客户端缓冲区头指针
int m_clt_read_idx; //客户目前读取到的位置
int m_clt_write_idx; //客户目前写到的位置
sockaddr_in m_clt_address; //客户地址
int m_cltfd; //客户fd
char* m_srv_buf;
int m_srv_read_idx;
int m_srv_write_idx;
sockaddr_in m_srv_address;
int m_srvfd;
bool m_srv_closed; //服务器关闭标志位
};
#endif