diff -r 732576fa8a0d -r 1d6924779df7 PortMapper/MYPortMapper.m --- a/PortMapper/MYPortMapper.m Mon Apr 27 09:03:56 2009 -0700 +++ b/PortMapper/MYPortMapper.m Wed Apr 29 13:29:31 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); }