📄 clientsocket.cpp
字号:
// ClientSocket.cpp : implementation file
//
#include "stdafx.h"
#include "MsgClient.h"
#include "ClientSocket.h"
#include "MsgClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientSocket
CClientSocket::CClientSocket( CMsgClientDlg *CMsgClientDlg)
{
}
CClientSocket::~CClientSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CClientSocket, CSocket)
//{{AFX_MSG_MAP(CClientSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CClientSocket member functions
void CClientSocket::OnReceive(int nErrorCode)
{
CMsgClientDlg* pDlg=(CMsgClientDlg*)::AfxGetMainWnd();
BYTE tempMsg[6000];
int ByteCount; //每次读取的字符个数
int EndFlag=0; //接收完毕的标志
do
{
ByteCount=Receive(tempMsg,6000);
if(ByteCount>6000||ByteCount<=0)
{
AfxMessageBox("接收数据中出错");
return;
}
else if(ByteCount<6000 && ByteCount>0)
{
EndFlag=1;
}
//保证结束位被加上
tempMsg[ByteCount]=0;
}while(EndFlag==0);
CString Temp;
char czTemp[6000];
//Temp.Format("%s",tempMsg);
memcpy(czTemp,tempMsg,sizeof(tempMsg));
if ( strstr(czTemp,"NO_DATA") )
{
//AfxMessageBox("NO_DATA");
::PostMessage(pDlg->m_hWnd,WM_USER_RECEIVE_MSG,0,NULL);
}
else
{
memcpy(pDlg->tempMsg, tempMsg,sizeof(tempMsg));
::PostMessage(pDlg->m_hWnd,WM_USER_RECEIVE_MSG,ByteCount,NULL);
}
pDlg->DisConnect();
CSocket::OnReceive(nErrorCode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -