CFSocketCreateRunLoopSource crashes
CFSocketCreateRunLoopSource crashes
- Subject: CFSocketCreateRunLoopSource crashes
- From: Liwei <email@hidden>
- Date: Sun, 24 Aug 2008 17:01:46 +0800
Hmm... Somehow the following code crashes while trying to create the
runloop source:
struct sockaddr_in a = {0, AF_INET, htons(5555), 0};
CFDataRef d = CFDataCreate(kCFAllocatorDefault, (UInt8 *)&a,
sizeof(struct sockaddr_in));
CFSocketSignature signature = {PF_INET, SOCK_DGRAM, IPPROTO_UDP, d};
CFSocketRef socket =
CFSocketCreateWithSocketSignature(kCFAllocatorDefault, &signature,
kCFSocketDataCallBack, receiveData, NULL);
CFRunLoopSourceRef source =
CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0);
CFRunLoopRef loop = CFRunLoopGetCurrent();
CFRunLoopAddSource(loop, source, kCFRunLoopDefaultMode);
The weird thing is that without htons() the code runs, but I don't
think the socket works. I'm on Intel by the way.
Anyone with any ideas?
_______________________________________________
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