Re: CFReadStreamGetBuffer doesn't work for HTTP streams?
Re: CFReadStreamGetBuffer doesn't work for HTTP streams?
- Subject: Re: CFReadStreamGetBuffer doesn't work for HTTP streams?
- From: Becky Willrich <email@hidden>
- Date: Mon, 8 Jul 2002 17:07:08 -0700
CFReadStreamGetBuffer is an optional optimization a la
CFStringGetCStringPtr - it will only return non-NULL if the underlying
stream supports it and if a convenient buffer is on-hand. If you want
to use it, you should always have code that will fall-back to calling
CFReadStreamRead() (which every read stream must support):
// I'm glossing over the details for managing the length of the
buffer...
if (myBuf = CFReadStreamGetBuffer(stream)) {
handleBuffer(myBuf);
} else {
// GetBuffer not supported for this stream
UInt8 buf[BUFSIZE];
CFReadStreamRead(stream, buf, BUFSIZE);
handleBuffer(buf);
}
REW
On Friday, July 5, 2002, at 09:08 AM, Tommy Knowlton wrote:
On my 10.1.5 development system, I seem to be experiencing that
CFReadStreamGetBuffer always writes 0 into its out parameter,
numBytesRead. I've tried negative, zero, and positive values for the
maxBytesToRead in parameter, all with the same result. I am guarding
my callback's kCFStreamEventHasBytesAvailable case with a call to
CFReadStreamHasBytesAvailable (because I believe this is a low-cost
way to guard against other bugs in CFNetwork), so I "know" there are
bytes there before I call CFReadStreamGetBuffer.
Does anyone know any "tricks" to correctly using CFReadStreamGetBytes?
Kind regards,
--Tk!
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.