package happy-eyeballs-lwt

  1. Overview
  2. Docs
Connecting to a remote host via IP version 4 or 6 using Lwt_unix

Install

Dune Dependency

Authors

Maintainers

Sources

happy-eyeballs-1.0.0.tbz
sha256=5ea47f841ab2b70c65e861f2aebf85231e5581be5344e0e34e8564d5a500fdad
sha512=0819413dfe7fccacdfd9c4b2832f2a88b074d3d7ce419e0050a5f5fd104202c8757fe9d4a7133f592b9b2452cae0581d257853f339563c6a133500e5fab77316

doc/happy-eyeballs-lwt/Happy_eyeballs_lwt/index.html

Module Happy_eyeballs_lwtSource

Sourcetype t

The type of the abstract state of happy eyeballs.

Sourcetype getaddrinfo = [ `A | `AAAA ] -> [ `host ] Domain_name.t -> (Ipaddr.Set.t, [ `Msg of string ]) result Lwt.t
Sourceval create : ?happy_eyeballs:Happy_eyeballs.t -> ?getaddrinfo:getaddrinfo -> ?timer_interval:int64 -> unit -> t

create ~happy_eyeballs ~getaddrinfo ~timer_interval () creates an initial state of happy eyeballs with the specified timeouts in nanoseconds - the default for timer_interval is Duration.of_ms 10.

Sourceval connect_host : t -> [ `host ] Domain_name.t -> int list -> ((Ipaddr.t * int) * Lwt_unix.file_descr, [ `Msg of string ]) result Lwt.t

connect_host t host ports establishes a connection to host on ports (tried in sequence).

Sourceval connect_ip : t -> (Ipaddr.t * int) list -> ((Ipaddr.t * int) * Lwt_unix.file_descr, [ `Msg of string ]) result Lwt.t

connect_ip t addresses establishes a connection to addresses.

  • raises Failure

    if addresses is the empty list.

Sourceval connect : t -> string -> int list -> ((Ipaddr.t * int) * Lwt_unix.file_descr, [ `Msg of string ]) result Lwt.t

connect t host ports establishes a connection to host on ports, which may be a host name, or an IP address.

  • raises Failure

    if ports is the empty list.

Sourceval inject : t -> getaddrinfo -> unit

inject t getaddrinfo injects a new domain-name resolver into the given happy-eyeballs instance. By default, the happy-eyeballs instance use Lwt_unix.getaddrinfo to be able to resolve domain-name. However, the user can choose to use its own implementation of a DNS resolver (like ocaml-dns).

So, the ceremony for using happy-eyeballs with your own DNS resolver is to create a happy-eyeballs instance, obtain an instance that can resolve domain names (such as ocaml-dns) and inject the latter's implementation into our first happy-eyeballs instance:

  let _ =
    let dns = Dns_client_lwt.create () in
    let happy_eyeballs = Dns_client_lwt.create_happy_eyeballs dns in
    Happy_eyeballs_lwt.connect happy_eyeballs "robur.coop" [ 443 ]
    >>= function
    | Ok (_, fd) -> ...
    | Error _ -> ...
OCaml

Innovation. Community. Security.