本文介绍了如何强制发送和recv数据c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
this code sometimes hang the system on recv
int CLTIUReadWrite::Read( char *data, int nbytes)
{
int nleft, nread;
char *ptr2;
ptr2 = data;
nleft = nbytes;
while (nleft > 0) {
nread = read(m_Client->Socket, ptr2, nleft);
if (nread < 0)
return nread;
else if (nread == 0)
break;
nleft -= nread;
ptr2 += nread;
}
return (nbytes - nleft);
}
void CLTIUReadWrite::Write( char *buff, int size)
{
int h = m_Client->Write(( char*)buff,false,size);
printf(" \n data write %i data actual %i \n ",h,size);
}
推荐答案
这篇关于如何强制发送和recv数据c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!