[SOLVED]: NSConnection rootProxyForConnectionWithRegisteredName fails to find connection
[SOLVED]: NSConnection rootProxyForConnectionWithRegisteredName fails to find connection
- Subject: [SOLVED]: NSConnection rootProxyForConnectionWithRegisteredName fails to find connection
- From: "Doug Knowles" <email@hidden>
- Date: Tue, 22 Aug 2006 21:26:48 -0400
For the record:
Some deeper digging in the archive for this list turned up the answer,
although I confess it seems counter-intuitive.
It turns out that the problem was not that the connection had failed
to be registered by name; it was registered, but on other threads it
returned a rootProxy of nil.
The fix was to change:
slQueryManagerConnection = [[NSConnection alloc]
initWithReceivePort:recvPort sendPort:sendPort];
to:
slQueryManagerConnection = [[NSConnection alloc]
initWithReceivePort:recvPort sendPort:sendPort:nil];
Leaving the sendPort as "nil" has no adverse effect on remote clients
being able to access the vended object, nor on the object being able
to invoke methods on remote objects passed to it. I can't figure out
why providing a sendPort was a bad thing, but I can live with the
solution.
On 8/21/06, Doug Knowles <email@hidden> wrote:
Hi, all,
I am trying to use distributed objects to communicate between threads.
In my main thread, I have a "manager" object that sets up a
connection for subordinate threads to use to onvoke methods on it.
The problem is that the connection can not be found by its registered
name.
The following snippet is direct from my application; the last two
lines were added for debugging to show that the newly registered
connection can not be found by its name.
NSPort *sendPort = [NSPort port];
NSPort *recvPort = [NSPort port];
slQueryManagerConnection = [[NSConnection alloc]
initWithReceivePort:recvPort sendPort:sendPort];
[slQueryManagerConnection setRootObject:self];
if ( [slQueryManagerConnection
registerName:@"SLNSpotlightQueryManager"] == NO ) {
NSAssert( NO, @"Failed to register query manager as server!" );
}
id managerProxy = [NSConnection
rootProxyForConnectionWithRegisteredName:@"SLNSpotlightQueryManager"
host:nil];
NSLog( @"Looking for connection, found: %@", managerProxy );
The assertion does not fail, so I assume the registration succeeds,
but the log displays:
2006-08-21 21:11:33.165 SLNavigator[6451] Looking for connection, found: (null)
I suspect I'm missing something really basic. Any ideas?
As always, TIA.
Doug K;
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden