summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/unixLabels.mli
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2004-04-09 13:25:23 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2004-04-09 13:25:23 +0000
commit641657c87b1285b2e428469540c9506e37c04eb6 (patch)
tree6e86edef934366055c430908b1e1ed779c102c9b /otherlibs/unix/unixLabels.mli
parentb9ba49e3101057a1197e5a3cad2ac66abdb0ed9b (diff)
Support IPv6
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6193 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/unix/unixLabels.mli')
-rw-r--r--otherlibs/unix/unixLabels.mli89
1 files changed, 83 insertions, 6 deletions
diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli
index 9cf0fe7e9..3ab7e6289 100644
--- a/otherlibs/unix/unixLabels.mli
+++ b/otherlibs/unix/unixLabels.mli
@@ -856,17 +856,32 @@ type inet_addr = Unix.inet_addr
(** The abstract type of Internet addresses. *)
val inet_addr_of_string : string -> inet_addr
-(** Conversions between string with the format [XXX.YYY.ZZZ.TTT]
- and Internet addresses. [inet_addr_of_string] raises [Failure]
- when given a string that does not match this format. *)
+(** Conversion from the printable representation of an Internet
+ address to its internal representation. The argument string
+ consists of 4 numbers separated by periods ([XXX.YYY.ZZZ.TTT])
+ for IPv4 addresses, and up to 8 numbers separated by colons
+ for IPv6 addresses. Raise [Failure] when given a string that
+ does not match these formats. *)
val string_of_inet_addr : inet_addr -> string
-(** See {!UnixLabels.inet_addr_of_string}. *)
+(** Return the printable representation of the given Internet address.
+ See {!Unix.inet_addr_of_string} for a description of the
+ printable representation. *)
val inet_addr_any : inet_addr
-(** A special Internet address, for use only with [bind], representing
+(** A special IPv4 address, for use only with [bind], representing
all the Internet addresses that the host machine possesses. *)
+val inet_addr_loopback : inet_addr
+(** A special IPv4 address representing the host machine ([127.0.0.1]). *)
+
+val inet6_addr_any : inet_addr
+(** A special IPv6 address, for use only with [bind], representing
+ all the Internet addresses that the host machine possesses. *)
+
+val inet6_addr_loopback : inet_addr
+(** A special IPv6 address representing the host machine ([::1]). *)
+
(** {6 Sockets} *)
@@ -875,6 +890,7 @@ type socket_domain =
Unix.socket_domain =
PF_UNIX (** Unix domain *)
| PF_INET (** Internet domain *)
+ | PF_INET6 (** Internet domain (IPv6) *)
(** The type of socket domains. *)
type socket_type =
@@ -896,6 +912,9 @@ type sockaddr =
domain; [addr] is the Internet address of the machine, and
[port] is the port number. *)
+val domain_of_sockaddr: sockaddr -> socket_domain
+(** Return the socket domain adequate for the given socket address. *)
+
val socket :
domain:socket_domain -> kind:socket_type -> protocol:int -> file_descr
(** Create a new socket in the given domain, and with the
@@ -1125,7 +1144,65 @@ val getservbyport : int -> protocol:string -> service_entry
(** Find an entry in [services] with the given service number,
or raise [Not_found]. *)
-
+type addr_info =
+ { ai_family : socket_domain; (** Socket domain *)
+ ai_socktype : socket_type; (** Socket type *)
+ ai_protocol : int; (** Socket protocol number *)
+ ai_addr : sockaddr; (** Address *)
+ ai_canonname : string (** Canonical host name *)
+ }
+(** Address information returned by {!Unix.getaddrinfo}. *)
+
+type getaddrinfo_option =
+ AI_FAMILY of socket_domain (** Impose the given socket domain *)
+ | AI_SOCKTYPE of socket_type (** Impose the given socket type *)
+ | AI_PROTOCOL of int (** Impose the given protocol *)
+ | AI_NUMERICHOST (** Do not call name resolver,
+ expect numeric IP address *)
+ | AI_CANONNAME (** Fill the [ai_canonname] field
+ of the result *)
+ | AI_PASSIVE (** Set address to ``any'' address
+ for use with {!Unix.bind} *)
+(** Options to {!Unix.getaddrinfo}. *)
+
+val getaddrinfo:
+ string -> string -> getaddrinfo_option list -> addr_info list
+(** [getaddrinfo host service opts] returns a list of {!Unix.addr_info}
+ records describing socket parameters and addresses suitable for
+ communicating with the given host and service. The empty list is
+ returned if the host or service names are unknown, or the constraints
+ expressed in [opts] cannot be satisfied.
+
+ [host] is either a host name or the string representation of an IP
+ address. [host] can be given as the empty string; in this case,
+ the ``any'' address or the ``loopback'' address are used,
+ depending whether [opts] contains [AI_PASSIVE].
+ [service] is either a service name or the string representation of
+ a port number. [service] can be given as the empty string;
+ in this case, the port field of the returned addresses is set to 0.
+ [opts] is a possibly empty list of options that allows the caller
+ to force a particular socket domain (e.g. IPv6 only, or IPv4 only)
+ or a particular socket type (e.g. TCP only or UDP only). *)
+
+type name_info =
+ { ni_hostname : string; (** Name or IP address of host *)
+ ni_service : string } (** Name of service or port number *)
+(** Host and service information returned by {!Unix.getnameinfo}. *)
+
+type getnameinfo_option =
+ NI_NOFQDN (** Do not qualify local host names *)
+ | NI_NUMERICHOST (** Always return host as IP address *)
+ | NI_NAMEREQD (** Fail if host name cannot be determined *)
+ | NI_NUMERICSERV (** Always return service as port number *)
+ | NI_DGRAM (** Consider the service as UDP-based
+ instead of the default TCP *)
+(** Options to {!Unix.getnameinfo}. *)
+
+val getnameinfo : sockaddr -> getnameinfo_option list -> name_info
+(** [getnameinfo addr opts] returns the host name and service name
+ corresponding to the socket address [addr]. [opts] is a possibly
+ empty list of options that governs how these names are obtained.
+ Raise [Not_found] if an error occurs. *)
(** {6 Terminal interface} *)