Napisalem sobie program do komunikacji sieciowej i moj problem polega tym ze recv() zwraca czasem dane z poprzedniej parti danych. Socket jest usatwiony w tryb nieblokowalny.
string NET::recive(void)
{
int max_size=1000,size,a=0,b=0;
string sBuffor;
char *cBufor;
sBuffor.clear();
do
{
do
{
cBufor=new char [max_size+1];
memset (cBufor,0,sizeof (cBufor));
recv (Polaczenie,cBufor,max_size,0);
size=strlen(cBufor);
sBuffor+=cBufor;
delete [] cBufor;
if (!(size>0)) b=0; else {b++; Sleep(500);}
}
while(size>0);
a++;
Sleep(500);
if (*debug==true)cout<<"Sleep ...."<<a<<"buffor "<<sBuffor.length()<<endl;
}
while((sBuffor.length()==0)&&(a<=40));
//while(strlen(cBufor)>max_size-1);
return sBuffor;
}