From owner-freebsd-questions@FreeBSD.ORG Thu Nov 15 01:13:32 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B0F216A46E for ; Thu, 15 Nov 2007 01:13:32 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 9DB2913C46B for ; Thu, 15 Nov 2007 01:13:31 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (dialup245.ach.sch.gr [81.186.70.245]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id lAF1D28I022576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 15 Nov 2007 03:13:13 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id lAF1D1TL002525; Thu, 15 Nov 2007 03:13:01 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id lAF1Cx35002524; Thu, 15 Nov 2007 03:12:59 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 15 Nov 2007 03:12:58 +0200 From: Giorgos Keramidas To: Andrew Falanga Message-ID: <20071115011258.GF1995@kobe.laptop> References: <340a29540711141421tda33970q79f85533fb5ba725@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <340a29540711141421tda33970q79f85533fb5ba725@mail.gmail.com> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.938, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.46, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: User Questions Subject: Re: Socket programming question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Nov 2007 01:13:32 -0000 On 2007-11-14 15:21, Andrew Falanga wrote: > Hi, > My question has to do with how someone would find out if a call to > socket(2) actually produced a socket. I know that the API works, I've > programmed with it many times, but is there a way to find out if 's' > returned by socket(2) is actually valid in whatever kernel structure > it is stored? I understand that I may have the process entirely mixed > up. But it seems to me that the socket is somehow known to the kernel > and I should be able to query the kernel somehow and discover if it is > valid. The socket() system call returns -1 when it fails. Isn't that sufficient? If not, why? What ``extra'' information would you expect from the kernel when socket() fails? > Let me know if my question doesn't make sense as worded and I'll try > to explain myself better. Another question related to this one, would > someone in this list know where the source code is, in the system > source tree, for the select call? Look for kern_select() in `/usr/src/sys/kern/sys_generic.c'.