recv receiving not whole data sometime
Posted
by
milo
on Stack Overflow
See other posts from Stack Overflow
or by milo
Published on 2010-12-22T13:19:29Z
Indexed on
2010/12/22
13:54 UTC
Read the original article
Hit count: 214
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.
© Stack Overflow or respective owner