LNTCPClient.cpp 803 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "stdafx.h"
  2. #include "LNTCPClient.h"
  3. #include "LNBuffer.h"
  4. CLNTCPClient::CLNTCPClient(void)
  5. {
  6. m_Handle = NULL;
  7. this->m_pBuffer = new CLNBuffer();
  8. }
  9. CLNTCPClient::~CLNTCPClient(void)
  10. {
  11. }
  12. void CLNTCPClient::ProcessPack(LPBYTE pPack, int nLen)
  13. {
  14. if (m_Handle){
  15. m_Handle->HandlePack(pPack, nLen, NULL, this);
  16. }
  17. else {
  18. ASSERT(0);
  19. }
  20. }
  21. void CLNTCPClient::SetProtocolHandler(CProtocolHandler* pHandle)
  22. {
  23. m_Handle = pHandle;
  24. }
  25. int CLNTCPClient::Send(const void* lpBuf, int nBufLen, int nFlags /*= 0*/)
  26. {
  27. if (CTCPClientSocket::IsConnected()){
  28. return CEventSocket::Send(lpBuf, nBufLen, nFlags);
  29. }
  30. return -1;
  31. }
  32. void CLNTCPClient::OnClose(int nErrorCode)
  33. {
  34. __super::OnClose(nErrorCode);
  35. }