IPAddress.m
changeset 34 1fadc382ece2
parent 28 732576fa8a0d
child 35 a9dd5ac5ff11
     1.1 --- a/IPAddress.m	Mon Apr 27 09:03:56 2009 -0700
     1.2 +++ b/IPAddress.m	Mon May 04 23:10:51 2009 -0700
     1.3 @@ -83,6 +83,15 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +- (id) initWithSockAddr: (const struct sockaddr*)sockaddr
     1.8 +                   port: (UInt16)port
     1.9 +{
    1.10 +    self = [self initWithSockAddr: sockaddr];
    1.11 +    if (self)
    1.12 +        _port = port;
    1.13 +    return self;
    1.14 +}
    1.15 +
    1.16  + (IPAddress*) addressOfSocket: (CFSocketNativeHandle)socket
    1.17  {
    1.18      uint8_t name[SOCK_MAXADDRLEN];
    1.19 @@ -241,10 +250,9 @@
    1.20          [self release];
    1.21          return nil;
    1.22      }
    1.23 -    self = [super initWithSockAddr: sockaddr];
    1.24 +    self = [super initWithSockAddr: sockaddr port: port];
    1.25      if( self ) {
    1.26          _hostname = [hostname copy];
    1.27 -        _port = port;
    1.28      }
    1.29      return self;
    1.30  }    
    1.31 @@ -278,15 +286,15 @@
    1.32      NSString *addr = self.ipv4name;
    1.33      if (addr)
    1.34          [desc appendFormat: @"(%@)", addr];
    1.35 -    if( _port )
    1.36 -        [desc appendFormat: @":%hu",_port];
    1.37 +    if( self.port )
    1.38 +        [desc appendFormat: @":%hu",self.port];
    1.39      return desc;
    1.40  }
    1.41  
    1.42  
    1.43  - (NSUInteger) hash
    1.44  {
    1.45 -    return [_hostname hash] ^ _port;
    1.46 +    return [_hostname hash] ^ self.port;
    1.47  }
    1.48  
    1.49