# GeoIP C lib bindings

**URL:** <https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421>\
**Category:** Ruby\
**Created:** [October 26, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421 "2007-10-26T19:22:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 26, 2007, 7:22pm UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421/1 "2007-10-26T19:22:17Z")

</div>

This is a library which provides a single function. The function takes  
as input an IP address and it outputs a hash containing best-guess  
geographical information (like city, country, latitude, and  
longitude).

Actually this is only a Ruby binding to a C library which provides  
this function. Also, you must download a large binary database with  
all this mapping information. It is kindly provided free of charge by  
[MaxMind.com](http://MaxMind.com).

There are other attempts at providing this functionality in Ruby but  
mine is very simple and fast.

[http://s3.amazonaws.com/four.livejournal/20071026/GeoIPCity-0.0.1.tgz](http://s3.amazonaws.com/four.livejournal/20071026/GeoIPCity-0.0.1.tgz)  
[http://s3.amazonaws.com/four.livejournal/20071026/GeoIPCity-0.0.1.gem](http://s3.amazonaws.com/four.livejournal/20071026/GeoIPCity-0.0.1.gem)

ry

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 27, 2007, 7:50am UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421/2 "2007-10-27T07:50:40Z")

</div>

ry dahl wrote:

> There are other attempts at providing this functionality in Ruby but  
> mine is very simple and fast.

Have you compared the performance of your library, Sean Chittendon’s  
previous library that also used the C back-end, and my pure-Ruby gem?

The disk I/O time dominates, so the difference in performance is almost  
imperceptible (or at least, depends on other things like the  
availability  
of physical memory, etc).

The pure Ruby version is much more convenient, of course. That’s why I  
wrote it to replace Sean’s version… I don’t think we needed still a  
third version.

Clifford H…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 27, 2007, 4:25pm UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421/3 "2007-10-27T16:25:45Z")

</div>

ry dahl wrote:

> If I remember correctly, Sean’s wasn’t working for the city database  
> and it was rather a large amount of code. This is just 79 lines of c -  
> so it is compact and does, probably, all of what people want it to do.  
> that is, if they have access to a compiler.

Sure. I’m certain there are times it’ll be useful.

Clifford H…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 27, 2007, 2:04pm UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421/4 "2007-10-27T14:04:11Z")

</div>

Hi Clifford,

If I remember correctly, Sean’s wasn’t working for the city database  
and it was rather a large amount of code. This is just 79 lines of c -  
so it is compact and does, probably, all of what people want it to do.  
that is, if they have access to a compiler.

The silly thing is I’ve spent more time “releasing” it than i did  
actually writing it 🙂

ry

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 28, 2007, 7:45pm UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421/5 "2007-10-28T19:45:52Z")

</div>

On Oct 26, 9:46 pm, Clifford H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The pure Ruby version is much more convenient, of course. That’s why I  
> wrote it to replace Sean’s version… I don’t think we needed still a  
> third version.
> 
> Clifford H…

Clifford,

What’s the URL for your all ruby code?

Mike B.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 29, 2007, 8:50am UTC](https://www.ruby-forum.com/t/geoip-c-lib-bindings/118421/6 "2007-10-29T08:50:45Z")

</div>

barjunk wrote:

> What’s the URL for your all ruby code?

gem install geoip

or, if you insist, [http://geoip.rubyforge.org](http://geoip.rubyforge.org) :-).

Clifford H., Data Constellation
