• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: DO over network
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DO over network


  • Subject: Re: DO over network
  • From: Wade Tregaskis <email@hidden>
  • Date: Sun, 24 Oct 2004 12:56:39 +1000

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.

Yes, but why do I *not* see this 60 seconds of not being able to rebind when I sleep 0.03 seconds before doing invalidate?

Because if you close your side before the other does, the connection is put into the TIME_WAIT state (or somesuch)... as such, the port is still in use, technically. If you wait a brief time (which is entirely dependant on network latency; there's no magic number) then the other side will close the connection and it will not be left in this TIME_WAIT state. At least, that's the gist of it.

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:.

This looks like more work than my current workaround of sleeping for 1/30 second.

But your workaround will probably not work reliably, since it's dependant on network latency.

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
  • Follow-Ups:
    • Re: DO over network
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >DO over network (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: DO over network (From: Wade Tregaskis <email@hidden>)
 >Re: DO over network (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Binding & Change Count
  • Next by Date: Re: DO over network
  • Previous by thread: Re: DO over network
  • Next by thread: Re: DO over network
  • Index(es):
    • Date
    • Thread