Distributed Objects - Am I missing something?
Distributed Objects - Am I missing something?
- Subject: Distributed Objects - Am I missing something?
- From: Lally Singh <email@hidden>
- Date: Wed, 24 Oct 2001 16:58:33 -0400
Hi, I'm doing a very simple distributed objects system and I'm having a
very basic problem.
I've got a server object that I'm trying to vend, and a client object
that would like to talk to it that's in another process.
My apologies for all the code, but it's mostly copied & pasted from the
documentation. (And later inspected after much reading!)
So, the init routine for the server object looks like:
- init
{
NSConnection *theConnection;
[super init];
printf("Creating connection...");
fflush(stdout);
theConnection = [NSConnection defaultConnection];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(connectionDidDie:)
name:NSConnectionDidDieNotification
object:theConnection];
[theConnection setRootObject:self];
if ([theConnection registerName:@"svr"] == NO) {
printf("Failed to register name\n");
}
[theConnection retain];
[theConnection setDelegate:self];
printf("done.\n");
...
}
And I have the delegate routine listed below to tell me when I get a
connection request.
- (BOOL)connection:(NSConnection *)parentConnection
shouldMakeNewConnection:(NSConnection *)newConnnection
{
printf("Got request to start a connection\n");
return YES;
}
This routine is never called and the client (running on the same
machine) fails to connect with this code:
m_server = [[NSConnection
rootProxyForConnectionWithRegisteredName:@"svr"
host:nil] retain];
if (m_server == nil) {
printf("couldn't connect with server\n");
}
[m_server setProtocolForProxy:@protocol(NetServerProto)];
[m_server registerClient: self withName: m_clientName];
The last line is a method call to the vended object directly, which
isn't called at all. They're both running on the same host.
If there isn't something obviously wrong, any pointers on where to go
next in debugging it? Perhaps some more documentation than what's
available in NSConnection?
Thanks in advance!
------
H. Lally Singh