From owner-freebsd-current@FreeBSD.ORG Sun May 21 04:04:21 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from localhost.my.domain (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id D720416A423 for ; Sun, 21 May 2006 04:04:20 +0000 (UTC) (envelope-from davidxu@freebsd.org) From: David Xu To: current@freebsd.org Date: Sun, 21 May 2006 12:04:10 +0800 User-Agent: KMail/1.8.2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200605211204.10259.davidxu@freebsd.org> Cc: Subject: 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 04:04:21 -0000 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); }