forked from xunshuidezhu/chatroom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.h
40 lines (35 loc) · 733 Bytes
/
Client.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
#ifndef CHATROOM_CLIENT_H
#define CHATROOM_CLIENT_H
#include <string>
#include "Common.h"
#include <sys/types.h>
using namespace std;
//client class...
class Client
{
public:
//constructor
Client();
//connect the server
void Connect();
//close the client
void Close();
//start the client
void Start();
private:
//the server socket
int sock;
//the process id
pid_t pid;
//the epoll_create return
int epfd;
//create pipe, fd[0] the father read, fd[1] the child write
int pipe_fd[2];
//if the client work
bool isClientWork;
//chat message buffer
char message[BUF_SZIE];
//server ip + port
sockaddr_in serverAddr;
};
#endif //CHATROOM_CLINET_H