Re: NSConnection via NSSocketPort
Re: NSConnection via NSSocketPort
- Subject: Re: NSConnection via NSSocketPort
- From: Cameron Hayne <email@hidden>
- Date: Sat, 15 Jun 2002 22:08:55 -0400
On Saturday, June 15, 2002, at 07:31 pm, John Anderson wrote:
That does indeed seem to be the issue, but I can't seem to find
anything in the Cocoa/Foundation classes to address this problem.
Any ideas on what I should do here?
Probably the best thing to do would be to ignore the problem. In my
experience, this is only a problem during development, when you are
testing. In the real deployed system, you would likely have the server
loop and wait a while until the port is available. And one hopes that
the server won't need to be restarted all that much in operations.
But, if you want to fix it anyway, you likely could do it by using the
BSD setsockopt system call after you ask the NSSocketPort what its
'socket' is.
On Friday, June 14, 2002, at 10:57 AM, Cameron Hayne wrote:
John Anderson <email@hidden> wrote:
I've got a client server solution that uses NSSocketPort-based
NSConnections to connect clients and servers over TCP/IP. All is fine
and dandy except that sometimes, when I quit and restart my server
application quickly, I can't set aside a port.
While I wouldn't have recognized it from the error messages you got,
the problem you described is a common one in socket programming. The
socket stays busy for a certain time after it is closed in case there
is still some data coming in that was delayed in transit. You can read
about this on the UNIX Socket FAQ page at:
http://www.developerweb.net/sock-faq/
It is explained (in probably too much detail) in the answer to the
question "Please explain the TIME_WAIT state".
One possible solution is via the socket option SO_REUSEADDR. (See the
question "What exactly does SO_REUSEADDR do?"
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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.