Re: DO over network
Re: DO over network
- Subject: Re: DO over network
- From: Wade Tregaskis <email@hidden>
- Date: Sun, 24 Oct 2004 03:27:30 +1000
1. tell all clients about my imminent demise (which prompts them to
cut and invalidate their connection)
2. usleep( 33333 )
3. [ connection invalidate]
4. [ receivePort invalidate]
When I omit step 2, a subsequent re-start of the server via:
[ [ NSSocketPort alloc] initWithTCPPort: portNbr ]
will return nil for the next minute. After this it will work ok.
When I sleep for less than 0.03 seconds the re-start sometimes fails.
What is going on here? What am I doing wrong?
Nothing... this sounds like the port is locking up, which is a result
of what happens when you let security people go crazy. Basically,
under most *nixes there is by default a period after a port is unbound
in which it cannot be rebound - this is what you're seeing with
initWithTCPPort returning nil. I think you're supposed to be able to
turn this "feature" *cough BS cough* off by setting the SO_REUSEADDR
[or whatever] option on the socket, but I've never seen this actually
work - presumably I'm doing something wrong though; many others have
fixed the problem by doing this. Anyway, see man setsockopt for
details. You will have to create your sockets manually (using
socket(), I would assume), set SO_REUSEADDR, and then initialise your
NSSocketPort's from that using
initWithProtocolFamily:socketType:protocol:socket:.
Wade Tregaskis (AIM, Yahoo & Skype: wadetregaskis, ICQ: 40056898, MSN &
email: email@hidden, Jabber:
email@hidden
-- Sed quis custodiet ipsos custodes?
_______________________________________________
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