recvbuf is 1500 bytes
and I know that I receive 820 times this buffer (cont=820 at the end of the while) that is 820*1500=1230000 bytes.
Wenn I open the file and I check the size, I have more than 1230000 bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14
char *memblock;
int i=0;
int size=0;
ifstream file ("test.txt", ios::in|ios::ate);
if (file.is_open())
{
size = (int) file.tellg();
memblock = newchar [size];// allocation of a memory block
file.seekg (0, ios::beg); // we set the get pointer at the beginning of the file
file.read (memblock, size);
file.close();
}
cout << "Size: " << size;
cout << "\n";
if I work with less data that this case, I mean if I test it with 2 recv buffer the file size is correct, 3000 bytes (1500+1500) but in the other case it doesn't work and I can't see the error.