Date: Mon, 23 Feb 2004 23:35:34 -0500 (EST) From: Robert Watson <rwatson@freebsd.org> To: "Ronald F. Guilmette" <rfg@monkeys.com> Cc: freebsd-net@freebsd.org Subject: Re: Finding all IPv4 addresses associated with INADDR_ANY (?) Message-ID: <Pine.NEB.3.96L.1040223233358.13645K-100000@fledge.watson.org> In-Reply-To: <46800.1077593230@monkeys.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 23 Feb 2004, Ronald F. Guilmette wrote: > Given a socket which has been properly created, opened, and then bound > to some port and the special INADDR_ANY ``wildcard'' address, I need to > be able to them programatically find all of the IPv4 addresses that the > socket was just bound to. > > Can anyone suggest a way to do this? > > Can anyone suggest a way to do this easily? > > Can anyone suggest a way to do this portably? In another e-mail, it's recommended that you try out getifaddrs(). This is almost certainly the best thing to do, but I wanted to point out one thing about the question you asked: when you bind a socket to INADDR_ANY, you're actually not saying "bind to all addresses available at the moment of binding", you're saying "bind to all addresses available at the moment of comparison". I.e., the PCB in kernel retains the value INADDR_ANY, and will match new IP addresses added to interfaces at some later time also. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Senior Research Scientist, McAfee Research
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1040223233358.13645K-100000>