inet_addr inet_ntoa

R

Rick Fiorentino

Hi All,

I tried looking up answers for this with little success...any help is
appreciated, bear with my newness to Ruby.

The application I am working on can store ip addresses in a DB. They are
accessed by different platforms so the plan is to store IPs in network
order and display as host order.

I cannot find the following routines in ruby land to aid with the
process:

inet_addr - to store the IP as network ordered
inet_ntoa - to retrieve the IP as host ordered

How do people deal with these conversions? I assume dealing with Endian
issues affects several of you folks?

Any help is greatly appreciated...sorry if this has been covered before.

Thanks,
Rick
 
B

Brian Candler

Hi All,

I tried looking up answers for this with little success...any help is
appreciated, bear with my newness to Ruby.

The application I am working on can store ip addresses in a DB. They are
accessed by different platforms so the plan is to store IPs in network
order and display as host order.

I cannot find the following routines in ruby land to aid with the
process:

inet_addr - to store the IP as network ordered
inet_ntoa - to retrieve the IP as host ordered

How do people deal with these conversions? I assume dealing with Endian
issues affects several of you folks?

Any help is greatly appreciated...sorry if this has been covered before.

Look at:

ri Array#pack
ri String#unpack

In particular, conversion "N" will pack as four bytes in network order
(big-endian)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top