site_archiver@lists.apple.com Delivered-To: macnetworkprog@lists.apple.com Some points: - (int)fdOutput { int result; CFDataRef fdData; result = -1; if (self.output != nil) { fdData = CFWriteStreamCopyProperty( (CFWriteStreamRef) self.output, kCFStreamPropertySocketNativeHandle ); if (fdData != nil) { assert(CFDataGetLength(fdData) == sizeof(result)); result = *(int *) CFDataGetBytePtr(fdData); CFRelease(fdData); } } return result; } S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware _______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (Macnetworkprog@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/macnetworkprog/site_archiver%40lists.... At 10:14 -0400 9/3/09, Vincent Lecours wrote: I have some troubles getting back the IP address back from the CFReadStream in my program. o kCFStreamPropertySocketNativeHandle won't return anything useful until the stream has been opened. You'll get back NULL in that case. o You don't need the CFSocketRef stuff. Once you have CFSocketNativeHandle, you can pass that directly to <x-man-page://2/getpeername>. o In your CFDataGetBytes call you should be passing in the sizeof(native) rather than CFDataGetLength(nativeProp). That way, if nativeProp is the wrong size (very unlikely), you won't have a buffer overrun. o You don't need the CFDataGetBytes call at all. You can just get a pointer to the bytes and indirect it. Here's some code I wrote to do this just today. It assumes that self.output is a NSOutputStream, which is toll-free bridged to CFWriteStream. This email sent to site_archiver@lists.apple.com