Over a million developers have joined DZone.

IP2Location C Library

·
IP2Location C Library enables the user to find the Country, Region, City, Latitude, Longitude, ZIP code, Time Zone, ISP, Domain name, Connection type, Area code and Weather station code of the location that any IP address or hostname originates from. 

This API is meant to allow easy integration between your program written in C language and the IP2Location Binary (.BIN) data file. Free download the code and data file at http://www.ip2location.com/download/C-IP2Location-3.0.0.tar.gz .

It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Locationâ„¢ binary databases for applications written in C or supporting static/dynamic library. Get more geolocation information at http://www.ip2location.com .


#include 

IP2Location *IP2LocationObj = IP2Location_open("../data/IP-COUNTRY-SAMPLE.BIN");
IP2LocationRecord *record = IP2Location_get_all(IP2LocationObj, "161.11.12.13");
printf("%s %s %s %s %s %f %f %s %s %s %s\n,
   record->country_short,
   record->country_long,
   record->region,
   record->city,
   record->isp,
   record->latitude,
   record->longitude,
   record->domain,
   record->zipcode,
   record->timezone,
   record->netspeed,
   record->iddcode,
   record->areacode,
   record->weatherstationcode,
   record->weatherstationname);
IP2Location_free_record(record);
IP2Location_close(IP2LocationObj);
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}