From owner-freebsd-current@FreeBSD.ORG Sun May 21 05:47:41 2006 Return-Path: X-Original-To: current@FreeBSD.ORG Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4978B16A421; Sun, 21 May 2006 05:47:41 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from sippysoft.com (gk.360sip.com [72.236.70.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id D34E243D46; Sun, 21 May 2006 05:47:40 +0000 (GMT) (envelope-from sobomax@sippysoft.com) Received: from sippysoft.com (localhost.360sip.com [127.0.0.1]) by sippysoft.com (8.13.6/8.13.6) with ESMTP id k4L5lddm083032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 20 May 2006 22:47:39 -0700 (PDT) (envelope-from sobomax@sippysoft.com) Received: (from sobomax@localhost) by sippysoft.com (8.13.6/8.13.6/Submit) id k4L5ldE0083031; Sat, 20 May 2006 22:47:39 -0700 (PDT) (envelope-from sobomax) Date: Sat, 20 May 2006 22:47:39 -0700 From: Maxim Sobolev To: David Xu Message-ID: <20060521054739.GA82826@gk.360sip.com> References: <200605211204.10259.davidxu@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200605211204.10259.davidxu@freebsd.org> User-Agent: Mutt/1.4.2.1i Cc: current@FreeBSD.ORG Subject: Re: couldn't bind to local address X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 May 2006 05:47:41 -0000 You forgot to bzero(3) addr. This is a common mistake - obviously it has nothing to do with AMD64. -Maxim On Sun, May 21, 2006 at 12:04:10PM +0800, David Xu wrote: > It is very weired that on AMD64, bind() can not bind to local address, > the following code prints out "bind(): Can't assign requested address". > > David Xu > --- > > > include > #include > #include > > int main() > { > struct sockaddr_in addr; > int s; > > s = socket(AF_INET, SOCK_STREAM, 0); > if (s == -1) { > perror("socket()"); > return (1); > } > > addr.sin_family = AF_INET; > addr.sin_port = htons(9000); > addr.sin_addr.s_addr = inet_addr("127.0.0.1"); > > if (bind(s, (struct sockaddr *)&addr, sizeof(addr))) { > perror("bind()"); > return (2); > } > > close(s); > return (0); > } > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >