Re: Distributed object vending problem
Others seem to have found http://www.thotzy.com/THOTZY/Distributed_Objects_Demo.html -- to be useful. ___ 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 arch...@mail-archive.com
Distributed object vending problem
Hi I'm writing two apps: A server and client and am having some trouble figuring exactly what to link to in the client program. The server application has a main class that has dozens of dependencies. I don't want to have to import all the server app dependencies into the client application as that defeats the purpose of factoring code into separate apps. How do I send messages to a server's vended object without having to include the server's entire dependency tree? I looked into protocols and proxies but am not sure which to use. Any help appreciated.___ 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 arch...@mail-archive.com
re; Distributed object vending problem
How do I send messages to a server's vended object without having to include the server's entire dependency tree? Incorporate the methods that you actually need for remote interaction into a protocol that is defined in a separate .h file, and #import it at both ends of the connection. You want to do that anyway to specify the special DO properties for those methods (bycopy, oneway, et al). To keep things clean on the server end, I would factor out the same methods into a category on the server class. The category then implements the protocol compliance. If you are communication across the wire I highly recommend oneway void methods with explicit bycopy params, BTW -- combined with async callbacks (also oneway-void + bycopy) you get a robust system that will survive real-world issues better. ___ 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 arch...@mail-archive.com
Re: Distributed object vending problem
On Sep 18, 2010, at 11:14 AM, Ken Tozier wrote: I'm writing two apps: A server and client and am having some trouble figuring exactly what to link to in the client program. The server application has a main class that has dozens of dependencies. I don't want to have to import all the server app dependencies into the client application as that defeats the purpose of factoring code into separate apps. How do I send messages to a server's vended object without having to include the server's entire dependency tree? I looked into protocols and proxies but am not sure which to use. The client shouldn't have or need any of the server's implementation code. You should define a protocol for the interface to the vended object in a header that's shared by both the client and the server. Then, cast the NSDistantObject* pointer returned by one of the rootProxy... methods to NSDistantObjectYourProtocolHere* (or, if you prefer, idYourProtocolHere). Then, just invoke the appropriate methods on it. The client should also use -[NSDistantObject setProtocolForProxy:] for efficiency. And the server should probably vend an NSProtocolChecker instead of the actual object. Any actual object is likely to have a number of private or internal-use-only methods on it, which you don't want accessible from client. The NSProtocolChecker makes sure that only the appropriate methods are accessible. The client code should have no mention of the actual class used on the server. Regards, Ken ___ 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 arch...@mail-archive.com
Re: Distributed object vending problem
Thanks Laurent. I followed the DO instructions here: http://www.informit.com/articles/article.aspx?p=1438422seqNum=3 but can't seem to get a connection to the server from my client app. Here's how I'm setting up the listener connection for the server server = [NSConnection new]; [server setRootObject: self]; [server registerName: @PMXServer withNameServer: [NSSocketPortNameServer sharedInstance]]; NSLog(@server: %@, server); Which seems to run OK, printing the following to the console server: (** NSConnection 0x114720 receivePort NSMachPort: 0x114850 sendPort NSMachPort: 0x114850 refCount 1 **) On the client end, I'm doing the following server = [[NSConnection rootProxyForConnectionWithRegisteredName: serverName // tried all of the following host: @localhost host: @10.0.1.3 host: @Ken-Toziers-MacBook-Pro.local host: nil usingNameServer: [NSSocketPortNameServer sharedInstance]] retain]; NSLog(@server: %@, server); But all I'm getting in the console is server: (null) Ultimately, the client and server will need to work on different machines on a network, thus the call to [NSSocketPortNameServer sharedInstance] Anyone see what I'm doing wrong? Thanks for any help On Sep 20, 2010, at 4:08 AM, Laurent Daudelin wrote: I haven't used DO since the NeXT days but if I recall correctly, it is very strongly suggested you use protocols for your methods. Using additional keywords, you can tell the runtime system what to expect when it sends your message from one process to another. For example, using oneway void will tell the runtime system that the message you're sending is not expecting a reply which can speed things up on a network. Your server objects should be receiving the remote messages and you need to find a way to dispatch the message to the correct destination based on the message's signature or other system you devise. As far as I remember, it was fairly simple to use. I don't really understand why you're worried about vending the whole server's tree. If you use protocols in your client and your server, sending a message to a distant object is not a problem. You first need to determine which messages you need to send to your server, then put them into a protocol and use DO additional keywords to let the runtime system about the behavior of your messages. Then, you just send to the server object you discover and it should work. -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/ Logiciels Nemesys Software laur...@nemesys-soft.com On Sep 18, 2010, at 09:14, Ken Tozier wrote: Hi I'm writing two apps: A server and client and am having some trouble figuring exactly what to link to in the client program. The server application has a main class that has dozens of dependencies. I don't want to have to import all the server app dependencies into the client application as that defeats the purpose of factoring code into separate apps. How do I send messages to a server's vended object without having to include the server's entire dependency tree? I looked into protocols and proxies but am not sure which to use. Any help appreciated.___ ___ 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 arch...@mail-archive.com
Re: Distributed object vending problem
On Sep 20, 2010, at 4:14 AM, Ken Tozier wrote: server: (** NSConnection 0x114720 receivePort NSMachPort: 0x114850 sendPort NSMachPort: 0x114850 refCount 1 **) Ultimately, the client and server will need to work on different machines on a network, thus the call to [NSSocketPortNameServer sharedInstance] Anyone see what I'm doing wrong? You are using a name server appropriate for socket ports but your connection is set up using Mach ports. Those two don't interoperate. You might be able to use +serviceConnectionWithName:rootObject:usingNameServer:. You can definitely use +connectionWithReceivePort:sendPort: with socket ports. It's probably easier to start with using Mach ports on a single machine and then switch to socket ports after you've got everything working. Regards, Ken ___ 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 arch...@mail-archive.com