1.1 --- a/IPAddress.m Wed Apr 22 16:45:39 2009 -0700
1.2 +++ b/IPAddress.m Mon Apr 27 09:03:56 2009 -0700
1.3 @@ -233,6 +233,22 @@
1.4 return self;
1.5 }
1.6
1.7 +- (id) initWithHostname: (NSString*)hostname
1.8 + sockaddr: (const struct sockaddr*)sockaddr
1.9 + port: (UInt16)port;
1.10 +{
1.11 + if( [hostname length]==0 ) {
1.12 + [self release];
1.13 + return nil;
1.14 + }
1.15 + self = [super initWithSockAddr: sockaddr];
1.16 + if( self ) {
1.17 + _hostname = [hostname copy];
1.18 + _port = port;
1.19 + }
1.20 + return self;
1.21 +}
1.22 +
1.23
1.24 - (void)encodeWithCoder:(NSCoder *)coder
1.25 {
1.26 @@ -256,6 +272,18 @@
1.27 }
1.28
1.29
1.30 +- (NSString*) description
1.31 +{
1.32 + NSMutableString *desc = [_hostname mutableCopy];
1.33 + NSString *addr = self.ipv4name;
1.34 + if (addr)
1.35 + [desc appendFormat: @"(%@)", addr];
1.36 + if( _port )
1.37 + [desc appendFormat: @":%hu",_port];
1.38 + return desc;
1.39 +}
1.40 +
1.41 +
1.42 - (NSUInteger) hash
1.43 {
1.44 return [_hostname hash] ^ _port;