accept () question

Jonathan I. Kamens jik at athena.mit.edu
Mon Mar 25 19:30:20 AEST 1991


  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 at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list