Subject: Re: getting UDP destination port/addresses
To: Michael Richardson <>
From: Andrew Brown <>
List: tech-net
Date: 01/07/2001 02:10:40
>  My recollection was that there was some way to get the destination
>address/port to which an UDP packet was sent by toggle either options to
>recvmsg(), or via setsockopt(). The option was in 4.3, I'm sure... But I
>haven't used it since.
>  Has it disappeared?
>  I hate having to open a socket for each address that exists (a la BIND,
>etc...) , and this is NetBSD specific.

using IP_RECVDSTADDR and recvmsg(2) (instead of read(2), recv(2), or
recvfrom(2)) works just fine for me.

i usually drop my own (admittedly non-thread safe) implementation of
recvfrom(2) into program that i write that use udp that stuffs the
receiving ip address into a global for me to look at.

|-----< "CODE WARRIOR" >-----|             * "ah!  i see you have the internet (Andrew Brown)                that goes *ping*!"       * "information is power -- share the wealth."