|
发送端发送:
std::string temp("0123456789");
std::string data("01");
for (int i = 0;i<5;i++)
{
data = data + temp;
}
ACE_Message_Block *dataBuf;
ACE_NEW_NORETURN(dataBuf,ACE_Message_Block(1024));
dataBuf->copy(data.c_str());
this->ws.write( dataBuf,dataBuf->length());
接收端代码:
char buf[100]="";
peer.recv (buf,sizeof(buf));
ACE_OS::printf("buf=%s\n",buf);
能正常接收:buf=0101234567890123456789012345678901234567890123456789
但接收端代码改为
char buf[10]="";
int bc;
while(bc=peer.recv (buf, sizeof(buf),0)!=0)
{
ACE_OS::printf("buf=%s\n",buf);
}
能收到发送的内容,但是中间夹着乱码。各位高手帮忙分析下原因 |
|