From owner-freebsd-net@FreeBSD.ORG Fri Jan 11 19:15:07 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9C9B16A418 for ; Fri, 11 Jan 2008 19:15:07 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by mx1.freebsd.org (Postfix) with ESMTP id 8CAA813C457 for ; Fri, 11 Jan 2008 19:15:07 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id D6F4F88D24; Fri, 11 Jan 2008 14:15:06 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Fri, 11 Jan 2008 14:15:06 -0500 X-Sasl-enc: 2zsHZHZogOWnZ8fAZ/MkzEgtd8g7/sq42malng4sP855 1200078906 Received: from empiric.lon.incunabulum.net (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id 62E80D18E; Fri, 11 Jan 2008 14:15:06 -0500 (EST) Message-ID: <4787C039.6080205@FreeBSD.org> Date: Fri, 11 Jan 2008 19:15:05 +0000 From: "Bruce M. Simpson" User-Agent: Thunderbird 2.0.0.6 (X11/20070928) MIME-Version: 1.0 To: SnaiX References: <00a001c85457$5e9e9c00$1bdbd400$@com> In-Reply-To: <00a001c85457$5e9e9c00$1bdbd400$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: the socket can't bind? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2008 19:15:07 -0000 SnaiX wrote: > So it would run 1-4. but it reports EADDRINUSE after bind. > > Why? The stack assumes that SO_REUSEADDR is never cleared on a socket after it gets set. > How to resolve it? Should I dup() the fd? > Did you close the affected socket in (5) ? Presumably you are still trying to use the same port; is it a non-ephemeral port? You might want to consider SO_REUSEPORT although I believe FreeBSD doesn't fully support it for non-multicast. BMS