• 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
kCFSocketWriteCallBack
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

kCFSocketWriteCallBack


  • Subject: kCFSocketWriteCallBack
  • From: Jeremy Thompson <email@hidden>
  • Date: Fri, 15 Aug 2014 16:59:35 -0700
  • Thread-topic: kCFSocketWriteCallBack

What would the appropriate way to use this kind of callback.  I have a function that sets up the socket listener.  And starts the run loop.  It then  uses an kCFSocketAcceptCallBack to actually start receiving a connection.  That callback looks like this.  Would I want to register the write callback function in the receiveData function or register it here.  The code as it stands now works well but doesn't hold up with greater traffic/data.  I looked through CFSocket.h and it talks about write callback but I am unsure of the implementation.  I need to be able to get away from CFSocketSendData as it does seem to block, taking too much time.

~Jeremy

void acceptConnection(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, void *data, void *info)

{

 

    

CFSocketNativeHandle csock = *(CFSocketNativeHandle *)data;

CFSocketRef sn;

CFRunLoopSourceRef source;

    CFSocketContext context;

    context.version = 0;

    context.info = New_Handle(0);

    context.retain = NULL;

    context.release = NULL;

    context.copyDescription = NULL;

    printf("acceptConnection context.info is %ld\n", context.info);

printf("Server socket %d received connection socket %d\n",  CFSocketGetNative(s), csock);

    


sn = CFSocketCreateWithNative(NULL, csock,kCFSocketDataCallBack, receiveData, &context);

source = CFSocketCreateRunLoopSource(NULL, sn, 0);

CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);

CFRelease(source);

CFRelease(sn);

}

 _______________________________________________
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

  • Follow-Ups:
    • Re: kCFSocketWriteCallBack
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Prev by Date: Re: CFsockets and speed of execution
  • Next by Date: Re: kCFSocketWriteCallBack
  • Previous by thread: Re: CFsockets and speed of execution
  • Next by thread: Re: kCFSocketWriteCallBack
  • Index(es):
    • Date
    • Thread