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.
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);
}