NSConnection - is this expected behavior?
NSConnection - is this expected behavior?
- Subject: NSConnection - is this expected behavior?
- From: Neil Clayton <email@hidden>
- Date: Mon, 19 Feb 2007 16:35:05 +1300
I have a reasonably trivial NSConnection example that I'm using to
make a client that can kick off a server, and be able to reconnect to
that server at will.
Thus a typical test scenario is this:
1) Start server (the example is so trivial, that it has no code to
start the server itself).
2) Start the client. It connects automatically from within
awakeFromNib.
3) Tell the server to "go". It starts performing a long running
operation (20s).
4) Quit the client.
5) The server handles the NSConnectionDidDie and removes the client
from it's list of proxies. It continues it's long running
operation, but can't send any info back to anyway of course, because
there is no client to send it back to.
6) Restart the client. You'll notice that it doesn't reconnect until
the server has completed it's first long running operation.
I would expect that the client would be able to get a new connection
to the server, and then receive updates. This does not appear to be
the case. Instead, the client hangs until the server has completed
it's long running operation, and only then is able to connect.
If I enable multithreading on the server via runInNewThread, then the
server (after its long running operation) spins up to about 70% CPU -
and still hangs.
Is NSConnection (and the associated DO implementation) limited to a
single thread, single call? Does it not handle multiple clients very
well? I don't wish to sound critical, but it would seem that this
is a very basic requirement of any DO implementation.
Of course; I could have screwed something up - and I'm only happy to
be told that is the case.
I'd really like to learn what I'm doing wrong here (before I throw
NSConnection out the window and write my own socket based system,
which I really, really don't want do have to do) - so I've "made the
effort" and made full code available here (http://www.divshare.com/
download/139341-202), as well as a video showing the same code in
action here as well as the problem (http://www.divshare.com/download/
139341-202)
Can anyone help me? (btw - if you saw my previous post, this code
is simpler - it's about as simple as you can get with a client app,
with error handling, and a bit of core data).
---
Regards,
Neil Clayton
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden