recv receiving not whole data sometime
- by milo
hi all, i have following issue: here is the chunk of code:
void get_all_buf(int sock, std::string & inStr) {
int n = 1;
char c;
char temp[1024*1024];
bzero(temp, sizeof(temp));
n = recv(sock, temp, sizeof(temp), 0);
inStr = temp;
};
but sometimes recv returning not whole data (data length always less then sizeof(temp)), only it's part. write side always sends me whole data (i got it with sniffer). what matter? thx.
P.S. i know, good manner suggests me to check n (if (n < 0) perror ("error while receiving data), but it doesn't matter now - it's not reason of my problem.
P.S.2 i've forgot - it's blocking socket.