From owner-freebsd-current@FreeBSD.ORG Sat Apr 12 19:49:49 2003 Return-Path: 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 C569937B401 for ; Sat, 12 Apr 2003 19:49:49 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id D4B5043FB1 for ; Sat, 12 Apr 2003 19:49:48 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h3D2njA7042016; Sat, 12 Apr 2003 20:49:45 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 12 Apr 2003 20:49:12 -0600 (MDT) Message-Id: <20030412.204912.76964336.imp@bsdimp.com> To: BelletJr@aol.com From: "M. Warner Losh" In-Reply-To: <109.225ca595.2bc723f2@aol.com> References: <109.225ca595.2bc723f2@aol.com> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: current@freebsd.org Subject: Re: connect(2) behavior with unreacheable hosts X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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, 13 Apr 2003 02:49:50 -0000 In message: <109.225ca595.2bc723f2@aol.com> BelletJr@aol.com writes: : Why does not connect(2) return any error when trying to connect to a host : unreachable because of an infinite loop in the routes? No time-out occurs and : the value 0 is returned by connect(2). Hmmmmm, you are correct. I was sure that you were nuts, but on -current the following program returns no error at all... Telnet shows the same behavior. This is clearly wrong. #include #include #include #include #include int main(void) { int fd; struct in_addr addr; struct sockaddr_in sa; int flags; fd = socket(PF_INET, SOCK_STREAM, 0); inet_aton("1.2.3.4", &addr); sa.sin_len = sizeof(sa); sa.sin_family = AF_INET; sa.sin_port = htons(1234); memcpy(&sa.sin_addr, &addr, sizeof(addr)); if (connect(fd, (struct sockaddr *) &sa, sizeof(sa))) err(1, "connect"); exit(0); }