package eio

  1. Overview
  2. Docs

Mock Eio.Net networks and sockets.

type t = [ `Generic | `Mock ] Eio.Net.ty Eio.Std.r
type listening_socket = [ `Generic | `Mock ] Eio.Net.listening_socket_ty Eio.Std.r
val make : string -> t

make label is a new mock network.

val on_connect : t -> _ Eio.Net.stream_socket 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 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 : ?listening_addr:Eio.Net.Sockaddr.stream -> string -> listening_socket

listening_socket label can be configured to provide mock connections.

If listening_addr is not provided, a dummy value will be reported.

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