• 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
NSConnection registered names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSConnection registered names


  • Subject: NSConnection registered names
  • From: Thomas Harrington <email@hidden>
  • Date: Tue, 10 Sep 2002 21:38:42 -0600

I have some code which does some simple DO vending that's picked up by
another process. Tonight I had a problem where -[NSConnection
registerName] would fail, although I could remedy the problem by just
changing the name I was using.

Presumably, at some point when my project crashed, the name remained
registered with the OS and was therefore unavailable on future
attempts. This got me thinking about reliability. As bad as it is if
my app crashes unexpectedly, it's much, much worse if such a crash
means that it won't ever work again until the user reboots. So I'm
thinking I need to uniquify the registered names somehow.

At the moment I'm using a scheme based on process IDs, which seems to
work:

In process A, which vends the object:
NSConnection *theConnection = [NSConnection defaultConnection];
NSString *connectionName = [NSString stringWithFormat:@"Foo%d",
getpid()]; // use process ID
if (![theConnection registerName:connectionName]) {
// handle the error
}

Process B accesses the object, and is always started up by process A:
NSString *connectionName = [NSString stringWithFormat:@"Foo%d",
getppid()]; // use parent PID
NSConnection *theConnection = [NSConnection
connectionWithRegisteredName:connectionName
host:nil];

The A/B process relationship means that A gets the same value for
getpid() as B gets for getppid(), and this scheme means that the name
is different each time the app runs.

Does this scheme seem to make sense, or am I likely to regret it at
some point? If A wants to run B more than once, should the name be
different each time?

--
Tom Harrington
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: (More) Re: NSAppleEventDescriptor/AEKeyword question
  • Next by Date: Re: [newbie] NSString code so it won't leak
  • Previous by thread: Audio library
  • Next by thread: Validating NSControl
  • Index(es):
    • Date
    • Thread