• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSHost not finding additional addresses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSHost not finding additional addresses


  • Subject: NSHost not finding additional addresses
  • From: Wade Tregaskis <email@hidden>
  • Date: Wed, 8 Oct 2003 20:29:58 +1000

The following code demonstrates the problem directly. 131.172.83.106 is my static IP.

int main (int argc, const char * argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSHost *hostA, *hostB;

hostA = [NSHost hostWithAddress:@"127.0.0.1"];
hostB = [NSHost hostWithAddress:@"131.172.83.106"];

if ([hostA isEqual:hostB]) {
NSLog(@"hostA isEqual hostB");
} else {
NSLog(@"hostA = %x, hostB = %x", hostA, hostB);
}

if ([hostA isEqualToHost:hostB]) {
NSLog(@"hostA isEqualToHost hostB");
} else {
NSLog(@"hostA addresses: %@\n\nhostB addresses: %@", [hostA addresses], [hostB addresses]);
}

[pool release];

return 0;
}

Both comparisons fail, indicating failure at two stages due to the same "bug". The NSHost cache should return the existing entity [hostA] when I created hostB. The two should also compare equally, since both point to the same host (localhost in this case, but this example probably works just as well for a remote host too).

The "bug" here is obviously that NSHost is not 'noticing' the extra addresses associated with any particular address I give it. In particular, the output of the above is as follows:

2003-10-08 20:16:58.286 NSHost bug[1532] hostA = 9daa0, hostB = 96b20
2003-10-08 20:16:58.288 NSHost bug[1532] hostA addresses: <CFArray 0x9b310 [0xa01303fc]>{type = mutable-small, count = 1, values = (
0 : <CFString 0x94840 [0xa01303fc]>{contents = "127.0.0.1"}
)}

hostB addresses: <CFArray 0x9fe70 [0xa01303fc]>{type = mutable-small, count = 1, values = (
0 : <CFString 0xa5830 [0xa01303fc]>{contents = "131.172.83.106"}
)}

This is giving me quite a headache, since I need to match connections to avoid creating duplicate connections. Is there anything I should be doing to make the host's realise there are alternative addresses for themselves? Even if I delay the comparison [by up to 15 seconds], allowing for any sort of lookup or whatever, nothing changes.

If this in indeed a bug, does anyone have a workaround? Presumably there's some way to get all the addresses (and optionally names) of a machine [local or remote] without resorting to a lookup? Performance is important, as I'll be comparing hundreds of hosts a second.

Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: AppleTalk/OpenTransport MacOS X Problem
  • Next by Date: Re: AppleTalk/OpenTransport MacOS X Problem
  • Previous by thread: Re: AppleTalk/OpenTransport MacOS X Problem
  • Next by thread: Re: NSHost not finding additional addresses
  • Index(es):
    • Date
    • Thread