package eio

  1. Overview
  2. Docs

IP addresses.

type 'a t = private string

The raw bytes of the IP address. It is either 4 bytes long (for an IPv4 address) or 16 bytes long (for IPv6).

module V4 : sig ... end

IPv4 addresses.

module V6 : sig ... end

IPv6 addresses.

val pp : [< `V4 | `V6 ] t Fmt.t

pp formats IP addresses. For IPv6 addresses, it follows http://tools.ietf.org/html/rfc5952.

type v4v6 = [ `V4 | `V6 ] t
val fold : v4:([> `V4 ] t -> 'a) -> v6:([> `V6 ] t -> 'a) -> [< `V4 | `V6 ] t -> 'a

fold ~v4 ~v6 t is v4 t if t is an IPv4 address, or v6 t if it's an IPv6 address.

Interoperability

To convert to or from OCaml Unix addresses, use Eio_unix.Ipaddr.

To interoperate with the ipaddr library:

  • Ipaddr.to_octets ipaddr_ip |> Eio.Net.Ipaddr.of_raw
  • Ipaddr.of_octets_exn (eio_ip :> string)
val of_raw : string -> v4v6

of_raw addr casts addr to an IP address.

  • raises Invalid_argument

    if it is not 4 or 16 bytes long.

OCaml

Innovation. Community. Security.