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 constructed on the exception
Unresolved defined below.
type unresolved =
| |
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
The exception type.
module P: Cf_socket.P with type AF.tag = unit and type ST.tag = unit
The unspecified socket protocol, used in composing hints.
val is_specific_socktype : unit Cf_socket.socktype -> 'a Cf_socket.socktype -> bool
Returns true if the socket types are equivalent.
val is_specific_domain : unit Cf_socket.sockaddr -> 'a Cf_socket.domain -> bool
Returns true if the socket address is of the specific domain.
val specialize_sockaddr : unit Cf_socket.sockaddr -> 'a Cf_socket.domain -> 'a Cf_socket.sockaddr
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. Raises Not_found
if the socket address is not of the appropriate address family.
type of_address_flags = {
|
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
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 ->
'a Cf_socket.sockaddr -> 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 = {
|
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
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 =
| |
A_nodename of string |
| |
A_servicename of string |
| |
A_bothnames of string * string |
The argument to the to_address function.
type ('a, 'b) addrinfo = private {
}
The type of elements in the list returned by the to_address function.
val addrinfo_hint : ?flags:to_address_flags ->
'a Cf_socket.domain ->
'b Cf_socket.socktype -> Cf_socket.protocol -> ('a, 'b) addrinfo
Construct a hints value for the to_address function.
val addrinfo_default_hint : (unit, unit) addrinfo
The default hints value for the to_address function, .
val to_addresses : ('a, 'b) addrinfo ->
to_address_arg -> ('a, 'b) addrinfo list
Use to_addresses hint arg to obtain a list of address information records
associated with the host name and/or service name provided in the argument
arg, using the hints provided in the hint argument.
val to_all_addresses : to_address_arg -> (unit, unit) addrinfo list
Use to_all_address arg to obtain a list of address information records
associated with the host name and/or service name provided in the argument
arg. The default hints are used.