Subject: Re: getting UDP destination port/addresses
To: Michael Richardson <mcr@sandelman.ottawa.on.ca>
From: Andrew Brown <atatat@atatdot.net>
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" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."