socket为什么收不到数据,在线等,急!
在一个发送线程内,如果用以下代码发送,接受端怎么也收不到数据
CFile file;
byte m_sendBuffer[4096]; //for async send
int m_nBytesBufferSize;
if(!file.Open(pThread->strSoureFilePath,CFile::modeRead ))
{
AfxMessageBox("文件打开失败");
return;
}
m_nBytesBufferSize=file.Read((void *)m_sendBuffer,1096);
while(m_nBytesBufferSize>0)
{
int i=pThread->pSocket->Send(m_sendBuffer,m_nBytesBufferSize);
m_nBytesBufferSize=file.Read((void *)m_sendBuffer,1096);
}
file.Close();
但是如果换成下面的代码,就可以收到了
while(1)
pThread->pSocket->Send("test",4);
其中pThread是当前线程指针,请问是什么原因造成的?