00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#ifndef _TCPIPCommReceive_h
00028
#define _TCPIPCommReceive_h
00029
00030
00031
00032
#include <winsock.h>
00033
#include "TraceObject.h"
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00051 class CTCPIPCommReceive :
virtual public CTraceObject
00052 {
00053
00054
public:
00055
00061
CTCPIPCommReceive(
const long MaxRecvBufferLen = 8192 );
00062
00064
virtual ~CTCPIPCommReceive();
00065
00066
00067
00068
00069
00070
00076
void Initialize(
const SOCKET Socket );
00077
00083
bool StartReceiving(
void );
00084
00090
int GetLastSocketError(
void )
const;
00091
00097
bool Terminating(
void )
const;
00098
00104
void Terminating(
bool Terminating );
00105
00106
00107
00108
protected:
00109
00110
00111
00112
00113
00120
virtual void Receive(
void *pData,
00121
long DataLen ) = 0;
00122
00123
00129
virtual void RecvDisInd(
void ) = 0;
00130
00131
00136
void InitializeClass(
const long MaxRecvBufferLen );
00137
00138
00139
private:
00140
00141
00142
00143
00149
static void RecvThread(
CTCPIPCommReceive *pClass );
00150
00151
00152 SOCKET m_Socket;
00153
int m_LastSocketError;
00154
00155 DWORD m_ThreadID;
00156
00157 HANDLE m_ThreadHandle;
00158 HANDLE m_hEventTerminate;
00159 HANDLE m_hEventTerminateFinished;
00160 HANDLE m_hEventStartReceiving;
00161
00162
void *m_pRecvBuffer;
00163
long m_MaxRecvBufferLen;
00164
00165
bool m_Terminating;
00166 };
00167
00168
00169
00170
00171
00172
00173
00174 inline int CTCPIPCommReceive::GetLastSocketError(
void )
const
00175
{
00176
return m_LastSocketError;
00177 }
00178
00179
00180 inline bool CTCPIPCommReceive::Terminating(
void )
const
00181
{
00182
return m_Terminating;
00183 }
00184
00185
00186 inline void CTCPIPCommReceive::Terminating(
bool Terminating )
00187 {
00188 m_Terminating = Terminating;
00189 }
00190
00191
00192
00193
#endif // _TCPIPCommReceive_h