diff -r 732576fa8a0d -r 6d1392a3e0a6 PortMapper/MYPortMapper.m --- a/PortMapper/MYPortMapper.m Mon Apr 27 09:03:56 2009 -0700 +++ b/PortMapper/MYPortMapper.m Tue Jun 23 13:52:28 2009 -0700 @@ -94,8 +94,6 @@ errorCode = kDNSServiceErr_NATPortMappingUnsupported; } } - if( errorCode != self.error ) - self.error = errorCode; [self priv_updateLocalAddress]; IPAddress *publicAddress = makeIPAddr(rawPublicAddress,publicPort); @@ -106,6 +104,8 @@ LogTo(PortMapper,@"%@: Public addr is %@ (mapped=%i)", self, self.publicAddress, self.isMapped); } + + [self gotResponse: errorCode]; [[NSNotificationCenter defaultCenter] postNotificationName: MYPortMapperChangedNotification object: self]; } @@ -135,22 +135,19 @@ } -- (DNSServiceRef) createServiceRef -{ +- (DNSServiceErrorType) createServiceRef: (DNSServiceRef*)sdRefPtr { DNSServiceProtocol protocols = 0; if( _mapTCP ) protocols |= kDNSServiceProtocol_TCP; if( _mapUDP ) protocols |= kDNSServiceProtocol_UDP; - DNSServiceRef serviceRef = NULL; - self.error = DNSServiceNATPortMappingCreate(&serviceRef, - 0 /*flags*/, - 0 /*interfaceIndex*/, - protocols, - htons(_localPort), - htons(_desiredPublicPort), - 0 /*ttl*/, - &portMapCallback, - self); - return serviceRef; + return DNSServiceNATPortMappingCreate(sdRefPtr, + kDNSServiceFlagsShareConnection, + 0 /*interfaceIndex*/, + protocols, + htons(_localPort), + htons(_desiredPublicPort), + 0 /*ttl*/, + &portMapCallback, + self); }