For the last several days I've been trying to use Distributed Objects in my application to no avail. I've scanned and scoured for multiple pieces of documentation over just about everywhere, I've tried one variation of code after another, initially trying to use NSSocketPort with domain sockets and then dropping down to NSMessagePorts w/ name server (to rule out any socket programming issues) and still nothing works.
The below is a mini-sized, minimalistic version of what I've been trying to write. It's largely based off the example I found in the Advanced Mac Programming book. My (simplified for the time being) goal is to create a foundation-tool based daemon that vends a communication object that will let a client Cocoa application connect and register as a client via distributed objects. The server seems to run okay, but the client tries to get the vended NSMessagePort sendPort, sendPort shows up as nil in the debugger. What am I doing wrong/misunderstanding? ######### Protocol ################################## #import <Foundation/Foundation.h> @protocol ClientMessages - (oneway void)printHelloWorld:(NSString *)barcode; @end @protocol ServerMessages - (BOOL)subscribeClient:(in byref id<ClientMessages>)newclient; @end ######### Daemon Code ################################ #import <Foundation/Foundation.h> #import "CommManager.h" int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSRunLoop *runloop = [NSRunLoop currentRunLoop]; CommManager *commManager = [[CommManager alloc] init]; NSMessagePort *receivePort = [[NSMessagePort alloc] init]; NSMessagePortNameServer *mpns = [NSMessagePortNameServer sharedInstance]; [mpns registerPort:receivePort name:@"CommServerPort"]; NSConnection *connection = [NSConnection connectionWithReceivePort:receivePort sendPort:nil]; [connection setRootObject: commManager]; [runloop run]; [pool drain]; return 0; } ####### CommManager.h ##################### #import <Foundation/Foundation.h> #import "CommProtocol.h" @interface CommManager : NSObject <ServerMessages> { NSMutableArray *clients; } @end ###### CommManager.m ###################### #import "CommManager.h" #import "CommProtocol.h" @implementation CommManager - (BOOL)subscribeClient:(in byref id<ClientMessages>)newclient { [clients addObject: newclient]; return YES; } - (void)dealloc { [clients release]; [super dealloc]; } @end ########### ClientController.h ################################# #import <Cocoa/Cocoa.h> #import "CommProtocol.h" @interface ClientController : NSObject <ClientMessages> { id proxy; } @end ########### ClientController.m ################################# #import "ClientController.h" @implementation ClientController - (void)awakeFromNib { NSMessagePortNameServer *nameServer = [NSMessagePortNameServer sharedInstance]; // sendPort shows up as nil in the debugger NSMessagePort *sendPort = [nameServer portForName:@"ChatterPort"]; NSConnection *connection = [NSConnection connectionWithReceivePort:nil sendPort: sendPort]; proxy = [[connection rootProxy] retain]; [proxy setProtocolForProxy:@protocol(ServerMessages)]; BOOL successful = [proxy subscribeClient: self]; if(successful) { NSLog(@"connected"); } else { NSLog(@"not connected"); } } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]