while it is a stream protocol, it is still broken into packets that get buffered up by the TCP/IP stack on the receiving machine. To get that data from those buffers to your app's buffers, you must repeatedly call NetLibReceive. There is no guarantee that the entire stream has been received (i.e. the sender is done) and is present in your machine's TCP/IP stack's buffers when you start trying to receive, nor can you be sure that the sender is finished when the TCP/IP stack tells you that it's buffers are empty.
"Dmitry Grinberg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > TCP is a STREAM protocol => there is no END of data, it is one > continuous stream. To see the end of http packer it seems reasonable > to call it with a small timout and assume end when you get a timeout. > > On 9/7/06, Palm <[EMAIL PROTECTED]> wrote: >> I am trying to receive an HTTP response from a web server using >> NetLibReceive and am trying to figure out how to tell when and if all of >> the >> data has been received. >> >> My understanding is that you should repeatedly call NetLibReceive, >> passing >> it a buffer and retrieving the received data from that buffer as >> NetLibReceive returns the number of bytes received into the buffer. When >> no >> more bytes are received, NetLibReceive should return 0, however that is >> not >> what I am seeing. I have yet to get a 0 result, and instead always get >> a -1 >> and timeout error signaled after having to wait for the timeout. >> >> For example: if the "number of bytes read" returned by the last call to >> NetLibReceive is less than the buffer size, how can you know for sure >> that >> the sender is not still sending data. I.e. ideally you should make one >> more >> call to NetLibReceive and expect to get a 0 back if the sender is done. >> However, doing this causes a full timeout delay and only raises a timeout >> error, which makes you have to guess whether this is a real timeout and >> the >> sender wasn't able to complete the transfer OR that the sender was indeed >> finished and shut down the connection. >> >> How is this typically handled? >> >> >> >> >> >> >> -- >> For information on using the PalmSource Developer Forums, or to >> unsubscribe, please see http://www.palmos.com/dev/support/forums/ >> > > > -- > Best Regards, Dmitry Grinberg > Software Engineer, http://PalmPowerups.com > (847) 226 9295 > AIM: DmitryGrinberg > MSN: [EMAIL PROTECTED] > ICQ: 165589894 > Y! IM: dmitrygr2003 > -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
