Re: NSSocketPort ipv6 vs ipv4 nightmare
Re: NSSocketPort ipv6 vs ipv4 nightmare
- Subject: Re: NSSocketPort ipv6 vs ipv4 nightmare
- From: j o a r <email@hidden>
- Date: Fri, 2 Sep 2005 09:40:56 +0200
On 2 sep 2005, at 09.16, Aurélien Hugelé wrote:
i would like to get the IP address (i would prefer IPv4 but can
manage using IPv6) of a NSSocketPort.
I've done something like this in the past:
==============================================
// Provides inet_ntoa
#import <netinet/in.h>
#include <arpa/inet.h>
/*
struct sockaddr_in {
u_char sin_len;
u_char sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
*/
@implementation NSSocketPort (Additions)
- (NSString *) addressString
{
struct sockaddr_in addrIn = *(struct sockaddr_in *)[[self
address] bytes];
NSString *address = [NSString stringWithFormat: @"%s", inet_ntoa
(addrIn.sin_addr)];
// NSLog(@"socketPort: %@", socketPort);
// NSLog(@"addrData: %@", addrData);
// NSLog(@"Port: %d", addrIn.sin_port);
// NSLog(@"Address: %@", address);
return address;
}
@end
==============================================
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden