From owner-freebsd-current@FreeBSD.ORG Fri May 6 03:09:02 2005 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 5275016A4D2 for ; Fri, 6 May 2005 03:09:02 +0000 (GMT) Received: from smtp.vzavenue.net (smtp.vzavenue.net [66.171.59.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id A5C4243D7E for ; Fri, 6 May 2005 03:09:01 +0000 (GMT) (envelope-from jr@opal.com) Received: from linwhf.opal.com (112.79.171.66.subscriber.vzavenue.net [66.171.79.112]) by smtp.vzavenue.net (MOS 3.4.8-GR) with ESMTP id CEF19472; Thu, 5 May 2005 23:08:41 -0400 (EDT) Received: from linwhf.opal.com (localhost [127.0.0.1]) by linwhf.opal.com (8.13.3/8.13.1) with ESMTP id j4638fmR037629 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Thu, 5 May 2005 23:08:41 -0400 (EDT) (envelope-from jr@linwhf.opal.com) Received: (from jr@localhost) by linwhf.opal.com (8.13.3/8.13.1/Submit) id j4638feo037628; Thu, 5 May 2005 23:08:41 -0400 (EDT) (envelope-from jr) Date: Thu, 5 May 2005 23:08:41 -0400 From: "J.R. Oldroyd" To: Brian Buchanan Message-ID: <20050506030841.GL51983@linwhf.opal.com> References: <20050506023318.GK51983@linwhf.opal.com> <20050505193739.Y36831@thought.holo.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050505193739.Y36831@thought.holo.org> User-Agent: Mutt/1.4.2.1i X-Junkmail-Status: score=0/50, host=smtp.vzavenue.net cc: freebsd-current@freebsd.org Subject: Re: async connect problem 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: Fri, 06 May 2005 03:09:02 -0000 On May 05, 19:39, Brian Buchanan wrote: > On Thu, 5 May 2005, J.R. Oldroyd wrote: > > >Isn't our behaviour wrong... > > > >On 6-current, the program below prints: > > connect: Connection refused > > > >Shouldn't it print: > > connect: Operation now in progress > > No, that's the correct behavior. The system was able to satisfy your > request without blocking because you were attempting a connection to the > loopback, so connect() returned immediately with errno == ECONNREFUSED. > > - Brian You are correct, it does return EINPROGRESS when using a non-loopback address. Perhaps I should ask a different question. Subsequent code to check the socket's status, something like: int n; socklen_t intsize = sizeof(int); getsockopt(f, SOL_SOCKET, SO_ERROR, (void*)&n, &intsize); if (n) ... which works (with suitable cast adjustments) on Solaris, Linux, Darwin, and yes, even on Windows, doesn't work here. I have an alternative test that uses getpeername(), but I'm surprised at the difference in behavior. -jr