package dns-client

  1. Overview
  2. Docs

A flow module based on blocking I/O on top of the Unix socket API.

TODO: Implement the connect timeout.

type context

A context is a network connection initialized by T.connect

type +'a io = 'a

io is the type of an effect. 'err is a polymorphic variant.

type io_addr = Ipaddr.t * int

An address for a given context type, usually this will consist of IP address + a TCP/IP or UDP/IP port number, but for some context types it can carry additional information for purposes of cryptographic verification.

type stack = unit

A stack with which to connect.

type t

The abstract state of a DNS client.

val create : ?nameservers:(Dns.proto * io_addr list) -> timeout:int64 -> stack -> t

create ~nameservers ~timeout stack creates the state record of the DNS client. We use timeout (ns) as a cumulative time budget for connect and request timeouts.

val nameservers : t -> Dns.proto * io_addr list

The address of a nameservers that is supposed to work with the underlying context, can be used if the user does not want to bother with configuring their own.

val rng : int -> Cstruct.t

rng t is a random number generator.

val clock : unit -> int64

clock t is the monotonic clock.

val connect : t -> (context, [> `Msg of string ]) Stdlib.result io

connect addr is a new connection (context) to addr, or an error.

val send : context -> Cstruct.t -> (unit, [> `Msg of string ]) Stdlib.result io

send context buffer sends buffer to the context upstream.

val recv : context -> (Cstruct.t, [> `Msg of string ]) Stdlib.result io

recv context tries to read a buffer from the context downstream.

val close : context -> unit io

close context closes the context, freeing up resources.

val bind : 'a io -> ('a -> 'b io) -> 'b io

a.k.a. >>=

val lift : 'a -> 'a io
OCaml

Innovation. Community. Security.