Re: Arguments for callback function
Re: Arguments for callback function
- Subject: Re: Arguments for callback function
- From: Eli Bach <email@hidden>
- Date: Sat, 2 Aug 2008 01:33:59 -0700
On Aug 2, 2008, at 1:03 AM, Liwei wrote:
But where do I pass the pointer to? I can't find it anywhere, its not
under CFWriteStreamSetClient nor CFWriteStreamScheduleWithRunLoop
Also, what are the client contexts for? From the documents, it sounds
similar to this as well...
2008/8/2 Eli Bach <email@hidden>:
On Aug 2, 2008, at 12:33 AM, Liwei wrote:
A quick question, I noticed that in the example code given for
CFNetwork specifically:
void myWriteCallBack(CFWriteStreamRef stream, CFStreamEventType
event, void *myPtr)
There is a third argument myPtr. I wonder if this is used to pass
information about the stream to the callback function. If this is
so,
how can I use it to pass a structure containing statistics about the
stream? Currently I'm declaring the structure global to be able to
access the information.
Yes, that's what its for. Just pass a pointer to your struct and
then in
the callback cast the void * back to mystruct * to update your
statistics.
It's not as obvious as it is for other API's, but you use:
CFReadStreamSetClient()
and
CFWriteStreamSetClient()
Since the 'client' is not a CF object, you would fill in the client
struct like this:
[this is copied from my working code, where the 'context' pointer
points to my C++ object]
contextInfo.version = 0;
contextInfo.info = this;
contextInfo.retain = nil;
contextInfo.release = nil;
contextInfo.copyDescription = nil;
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden