Thanks Laurent.
I followed the DO instructions here:
http://www.informit.com/articles/article.aspx?p=1438422&seqNum=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
> [email protected]
>
> 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 ([email protected])
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]