Re: Unbinding an endpoint in OT when running in Classic.
Re: Unbinding an endpoint in OT when running in Classic.
- Subject: Re: Unbinding an endpoint in OT when running in Classic.
- From: Justin Walker <email@hidden>
- Date: Tue, 13 Apr 2004 13:09:03 -0700
On Apr 13, 2004, at 12:41, Graham Parkinson-Morgan wrote:
I find that if I listen on a port in a PPC app running in Classic, I
can unbind the endpoint, close OT, shut down the app, fire the app
once more, rebind to the same port and listen as many times as I like.
However, if I then run a Carbon version of the same application on
OSX, immediately after shutting down the PPC version running in
Classic, OT tells me the port in question is still in use, and I find
that I have to shut down Classic before the port becomes available
once more.
The sequence used to shut down the asynchronous endpoint is:
OTSetSynchronous
OTUnbind
OTRemoveNotifier
OTCloseProvider
The error returns for this sequence are logged. Not a peep.
In any event, I would have thought that shutting down the application
would have been enough for the process manager inside Classic to tear
down any hold OT had on a port.
My question is, would there be anything else I can do to ensure that
Classic has relinquished control over this target port?
The issue is related to the rules of TCP port usage. A port has to
remain "out of the pool" after closure, for some amount of time, to
assure that late-arriving packets aren't delivered to the wrong
end-point.
To get around this, BSD-derived systems (as well as Linux, ...) provide
a couple of socket options: SO_REUSEADDR and SO_REUSE_PORT. These let
you shut down and restart a listener on a port without the "In use"
error you are seeing. See "man setsockopt".
Regards,
Justin
--
/~\ The ASCII Justin C. Walker, Curmudgeon-at-Large
\ / Ribbon Campaign
X Help cure HTML Email
/ \
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.