module Cf_nameinfo: sig
.. end
Domain name resolver interface.
Overview
This module is a wrapper over the C interface to the Domain Name Resolver
for IPv6 hosts. These functions typically block until network resources
respond to remote queries, sometimes within a few milliseconds. Some
exceptions are associated with conditions that take several seconds to
detect, e.g. no domain name service available.
Two functions are defined: to_address
and of_address
. Each function
takes an optional argument in the form of a record of boolean flags to
control the parameters of the query, much in the way the C interface to
the getaddrinfo()
and getnameinfo()
functions work.
Exceptions raised by the to_address
and of_address
functions are all
of variants of type unresolved_t
constructed on the exception
Unresolved
defined below.
type
unresolved_t =
| |
EAI_ADDRFAMILY |
| |
EAI_AGAIN |
| |
EAI_BADFLAGS |
| |
EAI_FAIL |
| |
EAI_FAMILY |
| |
EAI_MEMORY |
| |
EAI_NODATA |
| |
EAI_NONAME |
| |
EAI_SERVICE |
| |
EAI_SOCKTYPE |
| |
EAI_BADHINTS |
| |
EAI_PROTOCOL |
| |
EAI_UNKNOWN of int |
The sum type of exception conditions
exception Unresolved of unresolved_t
The exception type.
module AF: Cf_socket.AF
with
type tag_t = unit and
type address_t = unit Cf_socket.sockaddr_t
The unspecified address family.
val specialize_sockaddr : unit Cf_socket.sockaddr_t ->
'a Cf_socket.domain_t -> 'a Cf_socket.sockaddr_t option
Use specialize_sockaddr sa d
to specialize a socket address sa
from the
unspecified (or unknown) address family into a socket address of the
address family associated with the socket domain d
. Returns None
if
the socket address is not of the appropriate address family.
type
of_address_flags_t = {
|
ni_nofqdn : bool ; |
|
ni_numerichost : bool ; |
|
ni_namereqd : bool ; |
|
ni_numericserv : bool ; |
|
ni_dgram : bool ; |
}
The type of flags used with the of_address
function to control the
parameters of queries for host and service names.
val of_address_default_flags : of_address_flags_t
The default value of flags for the of_address
function below (all
flags set to false
).
val of_address : ?host:int ->
?serv:int ->
?flags:of_address_flags_t ->
'a Cf_socket.sockaddr_t -> string * string
Use of_address ?host ?serv ?flags sa
to resolve the name of the host and
the service associated with the socket address sa
. If the ?host
or
?serv
parameters are provided, they are used as the maximum length of the
returned host and/or service name, respectively. Returns an pair of
strings, the first is the host name and the second is the service name.
Raises Unix.Error
if there is an error.
type
to_address_flags_t = {
|
ai_passive : bool ; |
|
ai_canonname : bool ; |
|
ai_numerichost : bool ; |
}
The type of flags used with the to_address
function to control the
parameters of queries for host addresses and service numbers.
val to_address_default_flags : to_address_flags_t
The default value of ai_flags
record field for the hints provided to the
to_address
function below (all flags set to false
).
type
to_address_arg_t =
| |
A_nodename of string |
| |
A_servicename of string |
| |
A_bothnames of string * string |
The argument to the to_address
function.
type
addrinfo_t = {
}
The type of elements in the list returned by the to_address
function.
val addrinfo_default_hint : addrinfo_t
The default hints value for the to_address
function.
val to_address : ?hint:addrinfo_t ->
to_address_arg_t -> addrinfo_t list
Use to_address ?hint arg
to obtain a list of address information records
associated with the host name and/or service name provided in the argument
arg
and using the optional hints provided in the ?hint
argument.