Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ruby Programming Language

inet_addr inet_ntoa


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

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

Hi

On 5/30/07, Rick Fiorentino <rfiorent@charter.net> wrote:

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

> inet_addr - to store the IP as network ordered

  You can get the ip in network order using Socket.gethostbyname
(http://www.ruby-doc.org/core/classes/Socket.html#M002122)

--
Luis Parravicini
http://ktulu.com.ar/blog/

Look at:

  ri Array#pack
  ri String#unpack

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

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc