From owner-freebsd-current@FreeBSD.ORG Sun May 21 05:50:59 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 06E6916A45D; Sun, 21 May 2006 05:50:59 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2CE7F43D73; Sun, 21 May 2006 05:50:50 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (hha77re95nsi8n08@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.4/8.13.3) with ESMTP id k4L5ooV0059594; Sat, 20 May 2006 22:50:50 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.4/8.13.3/Submit) id k4L5onHg059593; Sat, 20 May 2006 22:50:49 -0700 (PDT) (envelope-from jmg) Date: Sat, 20 May 2006 22:50:49 -0700 From: John-Mark Gurney To: David Xu Message-ID: <20060521055049.GE770@funkthat.com> Mail-Followup-To: David Xu , current@freebsd.org 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 X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html 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 Reply-To: John-Mark Gurney 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:50:59 -0000 David Xu wrote this message on Sun, May 21, 2006 at 12:04 +0800: > 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". [...] > struct sockaddr_in addr; [...] > addr.sin_family = AF_INET; > addr.sin_port = htons(9000); > addr.sin_addr.s_addr = inet_addr("127.0.0.1"); You also forgot to initalized sin_len... I personally have adopted the policy of using getsockaddr to initalize my addr's... that way if sockaddr grows any additional fields, hopefully the kernel's getsockaddr will properly fill them out for me... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."