-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseSocketClient.h
More file actions
52 lines (43 loc) · 1.1 KB
/
BaseSocketClient.h
File metadata and controls
52 lines (43 loc) · 1.1 KB
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
/*
* =====================================================================================
*
* Filename: BaseSocketClient.h
*
* Description:
*
* Version: 1.0
* Created: 04/03/17 11:54:47
* Revision: none
* Compiler: g++
*
* Author: Feng Jie<[email protected]>
*
* =====================================================================================
*/
#ifndef __BASESOCKETCLIENT_H
#define __BASESOCKETCLIENT_H
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string>
#define MAX_RECV_LEN 512
class BaseSocketClient {
public:
BaseSocketClient(const char *remote, int port);
virtual ~BaseSocketClient();
// Top level APIs for callers
virtual bool start();
virtual bool shutdown();
protected:
bool create();
// May be overridden
virtual bool prepare() = 0;
virtual bool onSend(std::string &s) = 0;
virtual bool onReceive(std::string &s) = 0;
protected:
int mConnSock;
bool mShutdown;
sockaddr_in mAddr;
};
#endif /* __BASESOCKETCLIENT_H */