Re: Receive no data
- From: "Roger Hunen" <rhunen@xxxxxxxxx>
- Date: Fri, 7 Dec 2007 10:40:05 +0100
"mmlab_js" <mmlabjs@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote...
I modify the code on line 117:
do {
??recvbytes = recv(sockfd, recvbuf, recvbuflen, 0);
??if (recvbytes == SOCKET_ERROR)
????ErrExit(sockfd, "recv() failed with error: %d.\n", WSAGetLastError());
} while(recvbytes == 0);
If "no data available at this time", I think that it SHOULD receive some
data. But it doesn't.
I see two mistakes here:
1. "while(recvbytes == 0);". This should be "while (recvbytes > 0)". It may just be a
typo in your post though instead of actual code.
2. If multiple recv() calls receive data, each subsequent calls will overwrite the data
in the recvbuf that was store there by previous calls.
In order to receive the response data into a buffer first and process it later, you
should use something like:
offset = 0;
do {
recvbytes = recv(sockfd, recvbuf+offset, recvbuflen-offset, 0);
if (recvbytes == SOCKET_ERROR)
ErrExit(sockfd, "recv() failed with error: %d.\n", WSAGetLastError());
offset += recvbytes;
} while(recvbytes > 0);
Regards,
-Roger
--
E-mail: rhunen@xxxxxxxxx
Home: http://www.xs4all.nl/~rhunen
ADSL: http://adsl.hunen.net
.
- References:
- Re: Receive no data
- From: Volodymyr Shcherbyna
- Re: Receive no data
- From: Roger Hunen
- Re: Receive no data
- From: mmlab_js
- Re: Receive no data
- Prev by Date: Re: Receive no data
- Next by Date: Ack packets not standard
- Previous by thread: Re: Receive no data
- Next by thread: Re: Receive no data
- Index(es):