Re: How to do cancellable HTTP request using CFNetwork APIs

2010-05-09 Thread Jens Alfke
I would really recommend using the asynchronous APIs instead. It avoids bad behaviors like polling. Your current loop means you’re using CPU time even when no data is arriving, and can also waste up to 100ms sleeping when there’s data to read. And these make canceling pretty trivial since you’re

Re: How to do cancellable HTTP request using CFNetwork APIs

2010-05-09 Thread Bill Garrison
On May 8, 2010, at 3:18 PM, Kenny Leung wrote: > Hi All. > > I'm using CFNetwork APIs to create a cancellable web operation using the > synchronous, non-blocking APIs like so: [snip] > This is fine once you've gotten to the point of pulling the response, but I > would like the operation to a

How to do cancellable HTTP request using CFNetwork APIs

2010-05-08 Thread Kenny Leung
Hi All. I'm using CFNetwork APIs to create a cancellable web operation using the synchronous, non-blocking APIs like so: do { bytesRead = 0; if ( CFReadStreamHasBytesAvailable(inStream) ) { bytesRead = CFReadStreamRead(inStream, buffer, sizeof(buffer)); if ( bytesRea