Newsgroups: comp.unix.questions
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik
From: jik@athena.mit.edu (Jonathan I. Kamens)
Subject: Re: accept () question
Message-ID: <1991Mar25.093020.3183@athena.mit.edu>
Sender: news@athena.mit.edu (News system)
Organization: Massachusetts Institute of Technology
References:  <1991Mar25.003917.12347@brolga.cc.uq.oz.au>
Date: Mon, 25 Mar 91 09:30:20 GMT
Lines: 22

  Yes, you an specify null pointers for the addr and addrlen arguments to
accept().

  The kernel checks specifically if the addrlen pointer is null, and if it is,
does not attempt to fill the addr structure with anything.  This is equivalent
to saying, "I'm not really interested in the address from which the connection
originates, so don't bother to tell me."

  Note: I'm not 100% certain that this will work on all systems that support
accept(), so you might not want to rely on it.  It isn't a lot of effort to
allocate a sockaddr structure and pass it in, after all, so worrying about
whether or not passing in a null pointer will work on every architecture on
which you ever end up compiling your code may not be worth the hassle.

  Incidentally, the EFAULT error is for if the address is *non-null* and falls
outside the writeable part of the user address space.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710
