• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CFSocket questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFSocket questions


  • Subject: Re: CFSocket questions
  • From: "Edward Fink" <email@hidden>
  • Date: Tue, 10 Sep 2002 14:37:48 -0400

Well I tried several ways. The last way I tried looked something like this
if I remember correctly(not in front of my code).

CFSocketContext sc = {
CFIndex NULL;
void * 0;
const void *(*retain)(const void *info)&self;
void (*release)(const void *info)&self;
CFStringRef (*copyDescription)(const void *info)NULL;
}


I could have the syntax messed up (still new to Objective-C) but it was
something like what I have shown (if I remember correctly). Basically I tried
several ways to assign the CFSocketContext my Object address. However,
everything I had tried produced a crash when I tried to create the CFSocketRef.

<crash occurred at this point>
CFSocketRef s = CFSocketCreate(NULL, PF_INET, SOCK_STREAM, IPPROTO_TCP,
kCFSocketDataCallBack | kCFSocketConnectCallBack,
whatToDo, &sc);

I guess what I am asking is....exactly how do I do the assignment correctly?

Thanks,
Ed Fink

>We need to see the construction of sc to know what's going wrong. For
>instance, have you properly set the retain and release functions? The
>retain function will immediately be called on the info pointer, as
>
>realInfoPointer = sc.retain(sc.info);
>
>It's whatever's returned by sc.retain that will be given back to you in
>the callbacks....
>
>REW


On Monday, September 9, 2002, at 09:09 PM, Edward Fink wrote:

> I have tried what you suggested but apparently I am doing something
> wrong. I understand the concept and it seems like a great solution,
> however I must be missing something. I have tried many different ways
> but I cannot seem to get the info pointer assigned within the
> CFSocketContext to my object. I've looked at the CFSocket header file
> and the echo example in the developer docs but haven't figured it out.
> The program keeps crashing right when it does the CFSocketCreate w/my
> new CFSocketContext (shown below). Any help/suggestions would be
> great.
>
>
> CFSocketRef s = CFSocketCreate(NULL, PF_INET, SOCK_STREAM,
> IPPROTO_TCP,
> kCFSocketDataCallBack |
> kCFSocketConnectCallBack,
> whatToDo, &sc);
>
> On Monday, September 9, 2002, at 12:36 PM, Douglas Davidson wrote:
>>
>> For example: when you create the CFSocket, you can pass it a
>> CFSocketContext whose info is a pointer to the object you want to pair
>> with this particular socket. If you want the CFSocket to retain that
>> object, then you can set the retain and release pointers; otherwise
>> you can leave them NULL. When you get a callback, the last argument
>> to the callback function is that info pointer. Cast it to the type of
>> the object you are using, and then you can send messages to it.
_______________________________________________
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.

  • Follow-Ups:
    • Re: CFSocket questions
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: CFSocket questions
  • Next by Date: Re: CFSocket questions
  • Previous by thread: Re: CFSocket questions
  • Next by thread: Re: CFSocket questions
  • Index(es):
    • Date
    • Thread