Re: Symmetric Distributed Objects
Re: Symmetric Distributed Objects
- Subject: Re: Symmetric Distributed Objects
- From: "Jim Thomason" <email@hidden>
- Date: Tue, 18 Jul 2006 09:10:29 -0500
Someone please chime in and correct me if I've got it wrong or have
some of the details off...
But as I understand it, it's the socket implementation that's causing
this. There's nothing wrong with setting up the software to sometimes
be server and sometimes be client.
The problem is that, on occasion, the socket isn't being released when
one of the programs terminate. So when the other one comes along and
tries to connect, it can't because the old socket is blocking you.
It'll eventually time out on its own, but I don't know of any way to
kill it off in advance.
Making sure that you're always properly terminating your connections
and releasing your ports/etc will help alleviate the problem. But
you'll still smack into the issue if your app quits unexpectedly.
-Jim.....
On 7/18/06, Gerriet M. Denkmann <email@hidden> wrote:
I have two computers, both run identical copies of MyApp.
MyApp does at start:
p = [ NSSocketPort initWithTCPPort: 56789 ]
c = [NSConnection initWithReceivePort: p sendPort: nil ]
[ c setRootObject: self ]
[ NSNetService initWithDomain: @"" type: @"_MyApp._tcp." name:
hostname port: 56789] - publish.
[ NSNetServiceBrowser searchForServicesOfType: @"_MyApp._tcp."
inDomain: @"" ]
The NSNetServiceBrowser will find itself and MyApp on the other
computer.
Occasionally MyApp does:
[ NSNetService initWithDomain: @"local." type: @"_MyApp._tcp."
name: peerName ]; [ ns resolveWithTimeout: 2.7 ].
It gets an address, creates an NSPort, NSConnection.
Finally does proxy = [ connectionToPeer rootProxy ] and starts
talking to the peer.
This works ok 99% of the time.
But sometimes [ connectionToPeer rootProxy ] takes 75 seconds and
then returns nil.
Question: is this scenario - both copies of MyApp acting as server
and occasionally as client; both using the same port - ok?
Or is it principally wrong and only works by some happy chance?
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden