On Fri, Nov 27, 2009 at 6:46 AM, René v Amerongen <apple...@xs4all.nl> wrote: > Hello, > > I' am busy to make an old app up to date and want to use 100% 10.6 cocoa. > I have +75% percent done, but there is something what I can't figure out. > > Network calls are now using NSSocketPort, except a few that uses a fileHandle > or fileDescriptor to get an IP address, like: > > (NSFileHandle *) fh ... is known and come from another class > ... > CFSocketRef socket; > socket = CFSocketCreateWithNative (kCFAllocatorDefault, [fh fileDescriptor], > kCFSocketNoCallBack, NULL, NULL); > CFDataRef adrData = CFSocketCopyPeerAddress (socket); > struct sockaddr_in *sock = (struct sockaddr_in *)CFDataGetBytePtr(adrData); > NSString *address = [NSString stringWithCString:inet_ntoa(sock->sin_addr)]]; > ... > > How can I get the IP address from a fileHandle using Cocoa? > What is the Cocoa alternative of CFSocketCreateWithNative and > CFSocketCopyPeerAddress?
There's no Cocoa version of this, as far as I know. However, CFSocketCopyPeerAddress is just a wrapper around the POSIX function getpeername(), so you can just get the native socket from your NSSocketPort and then call that. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com