/
tcp_client.h
66 lines (48 loc) · 1.25 KB
/
tcp_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* @file TcpClient.h
* @brief TCP客户端实现代码
* @author hrh <huangrh@landuntec.com>
* @version 1.0.0
* @date 2011-12-07
*
* @verbatim
* ============================================================================
* Copyright (c) Shenzhen Landun technology Co.,Ltd. 2011
* All rights reserved.
*
* Use of this software is controlled by the terms and conditions found in the
* license agreenment under which this software has been supplied or provided.
* ============================================================================
*
* @endverbatim
*
*/
#ifndef _TCPCLIENT_H_
#define _TCPCLIENT_H_
#include "thread.h"
#include "ce_buffer.h"
//using namespace std;
struct _ClientInfo {
char addr[32];
};
class TcpClient : public Thread
{
public:
TcpClient();
~TcpClient();
void SetClient(struct _ClientInfo *info);
void SetConnectFlag(bool flag);
void ClearBuffer();
protected:
void Run();
private:
char client_addr[32]; //客户端IP地址
bool _connected_status; //是否已经连接到客户端
int local_sock; //连接到客户端的socket
bool _connect_flag; //是否要连接到客户端
void UploadClient();
void ConnectClient();
int SendData(struct cmemBuffer *image);
int SendHeartBeat();
};
#endif