求助:CAsyncSocket类套接字接收十六进制数据流出错
以下是服务器接收十六进制数据的函数:void CTcpServer1Dlg::OnReceive()
{
char* buff=new char[1000];
int nReceived;
CString strReceived,str1,str2,str3;
int nFlag=0;
nReceived=m_sConnectSocket.Receive(buff,1000);
do
{
if(nReceived==0)
{
nFlag=0;
}
else if(nReceived==NULL)
{
AfxMessageBox("接收数据出错!",MB_OK|MB_ICONSTOP);
return;
}
else if(nReceived>1000||nReceived<0)
{
AfxMessageBox("接收数据出错!",MB_OK|MB_ICONSTOP);
return;
}
else
{
for(int i=0;i<nReceived;i++)
{
str1.Format("%02X ",buff[i]);
str2+=str1;
}
nFlag=1;
}
}while(nFlag==0);
str3.Format("From Client: %s",str2);
m_listRecvData.AddString(str3);//接收数据列表框显示数据
UpdateData(FALSE);
}
编译后显示数据如下:
00
00 06 00 FFFFFF1B 0B 1F 15 00 FFFFFF5B 00 07 2B 3B EB
正常情况不应该出现“FFFFFF”这样的字符串,请问各位高手,这是怎么回事?应该怎样改?