-
Notifications
You must be signed in to change notification settings - Fork 11
/
UDPServer.h
41 lines (33 loc) · 957 Bytes
/
UDPServer.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 __UDP_SERVER_H__
#define __UDP_SERVER_H__
#include "OS_Define.h"
#include "InetAddr.h"
#include "Thread.h"
class UDPTransfer;
class UDPServer
{
public:
UDPServer();
virtual ~UDPServer();
public:
//设置监听端口;
void setBindAddr(const InetAddr& p_objInetAddr);
const InetAddr& getBindAddr()const;
int start();
void stop();
#ifdef WIN32
static THREAD_RESULT _stdcall UDPServerThread(void *pParam);
#else
static THREAD_RESULT UDPServerThread(void *pParam);
#endif
protected:
virtual int handleEvent(const char* p_pData, const int p_nDataLen, const InetAddr& p_objInetAddr);
private:
int run();
protected:
InetAddr m_objInetAddr; //监听地址
UDPTransfer* m_pobjListenTransfer; //监听传输器
thread_t m_nServerThreadId; //服务线程
bool m_bThreadRunFlag; //监听服务线程运行标记
};
#endif /*__UDP_SERVER_H__*/