package eio

  1. Overview
  2. Docs

Mock Eio.Net networks and sockets.

type t = < Eio.Net.t ; on_listen : Eio.Net.listening_socket Handler.t ; on_connect : < Eio.Net.stream_socket ; Eio.Flow.close > Handler.t ; on_datagram_socket : < Eio.Net.datagram_socket ; Eio.Flow.close > Handler.t ; on_getaddrinfo : Eio.Net.Sockaddr.t list Handler.t ; on_getnameinfo : (string * string) Handler.t >
type listening_socket = < Eio.Net.listening_socket ; on_accept : (Flow.t * Eio.Net.Sockaddr.stream) Handler.t >
val make : string -> t

make label is a new mock network.

val on_connect : t -> < Eio.Net.stream_socket ; Eio.Flow.close.. > Handler.actions -> unit

on_connect t actions configures what to do when a client tries to connect somewhere.

val on_listen : t -> Eio.Net.listening_socket Handler.actions -> unit

on_listen t actions configures what to do when a server starts listening for incoming connections.

val on_datagram_socket : t -> < Eio.Net.datagram_socket ; Eio.Flow.close.. > Handler.actions -> unit

on_datagram_socket t actions configures how to create datagram sockets.

val on_getaddrinfo : t -> Eio.Net.Sockaddr.t list Handler.actions -> unit
val on_getnameinfo : t -> (string * string) Handler.actions -> unit
val listening_socket : string -> listening_socket

listening_socket label can be configured to provide mock connections.

on_accept socket actions configures how to respond when the server calls "accept".

OCaml

Innovation. Community. Security.