sedj
Programmer
- Aug 6, 2002
- 5,610
Hi,
I have a recv() call on a socket :
Currently I am looking for a specific "end of data/stream character" - ie a tilde on the end of the data string, which if I see, then I break from the recv loop.
There must be some better way of doing this, but I can't figure out how.
I was expecting that the recv() call would return 0 or -1 at the end of the stream/data, but it never does. So if I don't send the "end of stream character", then recv() call just locks because the client thinks its sent all the data, but the server is still looking for more.
is this defined behaviour does recv() not return -1 or 0 or something when there is no more data ?
(Using linux, GCC 3.2)
Thanks ofr any help.
I have a recv() call on a socket :
Code:
while ((iRecvSize = recv(iSocketDesc, szRequestBuffer, REQUEST_SIZE-1, 0)) > 0) {
// extract data
}
Currently I am looking for a specific "end of data/stream character" - ie a tilde on the end of the data string, which if I see, then I break from the recv loop.
There must be some better way of doing this, but I can't figure out how.
I was expecting that the recv() call would return 0 or -1 at the end of the stream/data, but it never does. So if I don't send the "end of stream character", then recv() call just locks because the client thinks its sent all the data, but the server is still looking for more.
is this defined behaviour does recv() not return -1 or 0 or something when there is no more data ?
(Using linux, GCC 3.2)
Thanks ofr any help.