[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Get the subnet mask

David Corticchiato

12/19/2006 1:16:00 PM

Hi,

Is there another way of getting my subnet mask without parsing
ipconfig/ifconfig ?

David.

--
Posted via http://www.ruby-....

3 Answers

Jano Svitok

12/19/2006 2:51:00 PM

0

On 12/19/06, David Corticchiato <dcorticc@insia.org> wrote:
> Hi,
>
> Is there another way of getting my subnet mask without parsing
> ipconfig/ifconfig ?
>
> David.

On linux, look somewhere in the /proc

On windows there's some WINAPI for sure, but it could be PITA to go
through all the structures. Or try WMI (through Win32OLE) -- have look
at msdn.

It depends on your needs, but parsing ipconfig is the easiest way (be
sure to take care of localisation, we had problems when we moved from
english to, say italian windows.)

You can guess the netmask from the address class, but most probably
that won't work.

Daniel Berger

12/19/2006 2:57:00 PM

0

David Corticchiato wrote:
> Hi,
>
> Is there another way of getting my subnet mask without parsing
> ipconfig/ifconfig ?
>
> David.
>

There's IPAddr#mask, from the 'ipaddr' library (part of the stdlib).
Does that help?

Regards,

Dan

Shiwei Zhang

1/12/2007 4:28:00 AM

0


Daniel Berger wrote:

> David Corticchiato wrote:
>
>> Hi,
>>
>> Is there another way of getting my subnet mask without parsing
>> ipconfig/ifconfig ?
>>
>> David.
>>
>
> There's IPAddr#mask, from the 'ipaddr' library (part of the stdlib).
> Does that help?
>
> Regards,
>
> Dan
>
IPAddr#mask can't meet this requirement I think.
If the methods for these kinds of requirements (e.g., to get Subnet
Mask, Ip Addr of the local machine) are not available for now, should we
provide them in the near future?