Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Nov 2007 03:12:58 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Andrew Falanga <af300wsm@gmail.com>
Cc:        User Questions <freebsd-questions@freebsd.org>
Subject:   Re: Socket programming question
Message-ID:  <20071115011258.GF1995@kobe.laptop>
In-Reply-To: <340a29540711141421tda33970q79f85533fb5ba725@mail.gmail.com>
References:  <340a29540711141421tda33970q79f85533fb5ba725@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2007-11-14 15:21, Andrew Falanga <af300wsm@gmail.com> 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'.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071115011258.GF1995>