Subject: Re: Obtaining client IP address before accept(2)
To: Matthew Mondor <mm_lists@pulsar-zone.net>
From: Rui Paulo <rpaulo@NetBSD.org>
List: tech-kern
Date: 07/13/2005 14:11:00
On 2005.07.12 18:16:11 +0000, Matthew Mondor wrote:
 | It would be most useful for some of my applications to be able to know
 | the IP address of a client before calling accept(2), and to be able to
 | cancel that connection event without needing to accept(2) and close(2)
 | it.
 | 
 | I noticed that this feature is usually implemented differently on
 | various unix operating systems.  I verified if getsockopt(2) supported
 | an SO_GETADDR but it doesn't.  I am wondering if MSG_PEEK, or SCM_CREDS,
 | could provide a way to do this through ancillary data with recvmsg(2)?  I
 | haven't looked at the code yet, thought I would ask first if anyone
 | knows...
 | 
 | Also, if MSG_PEEK worked, how would I unqueue the event instead of
 | calling accept(2) if needed?

I think you can only check the IP address of an incomming connection by
using raw sockets.

		-- Rui Paulo