From owner-freebsd-questions Wed Sep 27 9: 2:33 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id DF1C337B423 for ; Wed, 27 Sep 2000 09:02:30 -0700 (PDT) Received: (from dan@localhost) by dan.emsphone.com (8.9.3/8.9.3) id LAA29486; Wed, 27 Sep 2000 11:02:03 -0500 (CDT) (envelope-from dan) Date: Wed, 27 Sep 2000 11:02:02 -0500 From: Dan Nelson To: Bjorn Tornqvist Cc: freebsd-questions@FreeBSD.ORG Subject: Re: bind(2) gives EADDRINUSE during 60 seconds. Why? Message-ID: <20000927110202.A13235@dan.emsphone.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.3.9i In-Reply-To: ; from "Bjorn Tornqvist" on Wed Sep 27 09:58:13 GMT 2000 X-OS: FreeBSD 5.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the last episode (Sep 27), Bjorn Tornqvist said: > I hope someone can explain this behaviour to me; The kernel seems to > make a stream port "un-rebindable" within 60 seconds after another > stream-server-process has had the port bound. > The easiest way to illustrate (with port/sysutils/socket): > Terminal one: Terminal two: > socket -s 19191 > telnet localhost 19191 > ^C > Connection closed by foreign host > socket -s 19191 > socket: server socket: Address already in use > > [wait 60 seconds] > ...and socket -s 19191 will succeed again. > > What is causing this? This behaviour causes my application to fail a > critical requirement and there must surely be something wrong with my > (aswell as socket(1)'s) interaction with the tcp/ip stack? You forgot to "i=1; setsockopt(s,SO_REUSEADDR,&i);". Please read the Unix Socket FAQ at http://www.lcg.org/sock-faq/ ; sections 2, 3 and 4. -- Dan Nelson dnelson@emsphone.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message