From owner-freebsd-hackers Sat Sep 15 19:36:46 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from enigma.jaded.net (enigma.jaded.net [216.94.132.9]) by hub.freebsd.org (Postfix) with ESMTP id 0643F37B405 for ; Sat, 15 Sep 2001 19:36:43 -0700 (PDT) Received: from spirit.jaded.net (unknown [216.94.132.8]) by enigma.jaded.net (Postfix) with ESMTP id 849B566B02; Sat, 15 Sep 2001 22:36:47 -0400 (EDT) Received: (from dan@localhost) by spirit.jaded.net (8.11.6/8.11.4) id f8G1CCx33461; Sat, 15 Sep 2001 21:12:12 -0400 (EDT) (envelope-from dan) Date: Sat, 15 Sep 2001 21:12:11 -0400 From: Dan Moschuk To: Stephen Montgomery-Smith Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Could not bind Message-ID: <20010915211211.A11699@spirit.jaded.net> References: <3BA3F70D.27C2136@math.missouri.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3BA3F70D.27C2136@math.missouri.edu>; from stephen@math.missouri.edu on Sat, Sep 15, 2001 at 07:49:17PM -0500 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG | I have written a server program that listens on port 3000. The program | works very well except for one feature. I am asking if that is normal, | or whether I forgot something. | | If I run the program it does fine. If I then kill the program (after it | has accepted connections), and then run the program again, the bind | function fails to work, and I get a message like "Could not bind" (see | program below). If I wait a while, like a minute or two, then the | program will work again. Is this normal behavior, or did I miss | something? [ snip ] This is normal behavior. bind() will fail if there are still sockets in the TIME_WAIT (and other) states. To get around this, you want to use set the SO_REUSEPORT option using setsockopt(). -Dan -- Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message