From: see@... (Douglas Wells) Date: 2007-07-19T09:10:08+09:00 Subject: Re: Listing all IP addresses on an multihomed system In article <1184796959.469021.157500@g12g2000prg.googlegroups.com>, Daniel Berger writes: > > > On Jul 18, 2:10 pm, s...@signature.invalid (Douglas Wells) wrote: > > In article <1184772029.010310.165...@j4g2000prf.googlegroups.com>, > > Daniel Berger writes: > > > > > I'm wondering if there's a way to list all IP addresses on a > > > multihomed system using Ruby's Socket API. I actually want this for > > > the sys-host library (athttp://www.rubyforge.org/projects/sysutils). > > > It's C, but I figure I can reverse engineer the Ruby code back to C. > > > > Most UNIX and Linux systems provide a mechanism to access this > > information via some variant of the ioctl(2) call with command > > SIOCGIFCONF. BSDi and FreeBSD have a set of subroutines (originally > > based on the ioctl) called getifaddrs. MS Windows WinSock2 uses > > the command SIO_GET_INTERFACE_LIST with the WSAIoctl procedure. > > You will need to look in the documentation for your system (and > > probably do a net search for programming examples) to see how it > > works. > > Indeed, there's an example in Stevens' "Unix Network Programming, Vol. > 1" staring at me now. :) Many thanks for the lead. I should be ok from > here (I hope). > > I'll see if I can come up with a pure Ruby solution and post it here > eventually. > > Dan Please let us know if you do. I managed to find time to take a slightly deeper look, and the problem that I found is that SIOCGIFCONF requires that you place an actual virtual address in the additional argument to ioctl. I doubt that there is a "pure Ruby" way of doing that. You'll can probably do ok getting the addresses associated with an interface name, however. - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- .