• 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: A intractable socket bind problem.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A intractable socket bind problem.


  • Subject: Re: A intractable socket bind problem.
  • From: John Labovitz <email@hidden>
  • Date: Mon, 14 Feb 2005 04:26:45 -0800

On Feb 14, 2005, at 1:07 AM, jacky.zhu wrote:

ret = setsockopt( mListen, SOL_SOCKET, SO_REUSEADDR, (char*)&sockOpt, sizeof(sockOpt) );
 
and the first process has already closed its listening socket, 
 
the second process can't bind its socket to the address and port until about a minute later .

(This really isn't a Cocoa question. It's pure BSD/POSIX.)

Try setting the SO_LINGER flag. That will reduce the time needed to clean up after a close if data is still waiting to be sent. (However, you may lose data.) I notice also that there's an SO_REUSEPORT option; perhaps you need that as well as SO_REUSEADDR.

You might also look into file-descriptor passing so you don't have to close & reopen the socket.

--
John Labovitz
Macintosh support, research, and software development
John Labovitz Consulting, LLC
email@hidden | +1 503.949.3492 | www.johnlabovitz.com/consulting


_______________________________________________
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


References: 
 >A intractable socket bind problem. (From: "jacky.zhu" <email@hidden>)

  • Prev by Date: Re: AuthorizationExecuteWithPrivileges(): implementation bug or correct behavior?
  • Next by Date: Formatting integer value
  • Previous by thread: A intractable socket bind problem.
  • Next by thread: Re: A intractable socket bind problem.
  • Index(es):
    • Date
    • Thread