Distributed Objects pitfalls and strategies
Distributed Objects pitfalls and strategies
- Subject: Distributed Objects pitfalls and strategies
- From: John Scalo <email@hidden>
- Date: Tue, 30 Mar 2004 00:44:57 -0800
Is there any reliable and resilient way to set up a DO server/client?
By reliable and resilient, I mean something that can withstand server
stops and starts, multiple user logout/logins, Panther fast user
switching, and deals with multiple clients and servers running on the
same network. It's not hard to get something that works most of the
time, but that's not good enough in this case. I've tried a few
different strategies, but each has its problems. From an earlier
discussion, the solution seemed to be to set up the BSD socket manually
and set the option to allow port reuse. But that introduces more
issues. Here are the things I've tried-
-- Neither client or server is set to reuse ports -- (aka Plain Ol'
Distributed Objects)
i.e. the server does this:
NSSocketPort *newPort = [[NSSocketPort alloc] initWithTCPPort:MYPORT];
NSConnection *connection = [[NSConnection alloc]
initWithReceivePort:newPort sendPort:newPort];
and the client does this:
NSSocketPort *connectionPort = [[NSSocketPort alloc]
initRemoteWithTCPPort:MYPORT host:ipAddressString];
NSConnection *connection = [[NSConnection alloc]
initWithReceivePort:NULL sendPort:connectionPort];
Problems:
* Client hangs when server disappears and then generates timeout
exceptions.
* Server can't make new NSSocketPorts after successive user
logout/logins for about 10 minutes.
-- Server set to reuse ports --
i.e. the server uses initWithProtocolFamily and the client uses
initRemoteWithProtocolFamily, setting up their own BSD socket
bind()ing, and listen()ing. Each calls setsockopt(newSocket,
SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) before binding.
Problems:
* Client hangs and gets timeout exceptions trying to resolve
connections after the server process has been stopped and started
again. e.g., a user logs out and another logs in.
-- Both set to reuse ports --
Problems:
* If there are multiple servers running on the network, then messages
sent to a connection's proxy go to a random server, not necessarily the
one the NSSocketPort was created for.
-- Use dynamic private ports --
Since port #s are unique, there isn't an issue of making new
connections, but this isn't workable if the user has a firewall, or
outside the local network.
So what is the right way to do this?
Thanks
~ John
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.