module HostIP:Interface to the Hostip.info service (see http://hostip.info). Copyright (C) 2005-2006 Merjis Ltd. $Id: HostIP.html,v 1.2 2006/04/01 10:30:51 rich Exp $sig..end
type t
val connection : ?connection:Http_client.pipeline -> ?cache_file:string -> unit -> t
The optional ~connection parameter is a pre-existing
Http_client.pipeline. If not supplied, one is created
for you.
The optional ~cache_file parameter allows you to specify
an external file in which previous searches are saved and
reloaded across runs of the library. The program should have
read/write access to this file, but the file is protected by
filesystem locks so may be safely shared across programs/users.
If the file doesn't exist, it is created.
See test.ml for examples.
val local_copy : ?data:string -> ?meta:string -> unit -> tlocal_copy ().
By default, looks for files in the local directory called
hostip_current.sql.data and hostip_current.sql.meta which
should have been created by you running hostip_local_copy_compile.
You can override the default filenames using optional ~data
and ~meta parameters.
See file README.local_copy.txt for more information.
val get_country_code : t -> string -> string optionget_country_code conn "12.215.42.19" ==> Some "US"
For the given IP address (in dotted quad format), return
the apparent originating ISO country code.
The result is cached in the connection object.val get_country_name : t -> string -> string optionget_country_name conn "12.215.42.19" ==> Some "UNITED STATES"
For the given IP address (in dotted quad format), return
the apparent originating country name.
The result is cached in the connection object.val get_city : t -> string -> string optionget_city conn "12.215.42.19" ==> Some "Sugar Grove, IL"
For the given IP address (in dotted quad format), return
the apparent originating city.
The result is cached in the connection object.val get_location : t -> string -> (string * string) optionget_location conn "12.215.42.19" ==> Some ("41.7696", "-88.4588")
For the given IP address (in dotted quad format), return
the apparent latitude and longitude.
The result is cached in the connection object.val clear_cache : t -> unitHostIP.local_copy.val forget : t -> string -> unitHostIP.local_copy.