package riot

  1. Overview
  2. Docs
An actor-model multi-core scheduler for OCaml 5

Install

Dune Dependency

Authors

Maintainers

Sources

riot-0.0.5.tbz
sha256=01b7b82ccc656b12b7315960d9df17eb4682b8f1af68e9fee33171fee1f9cf88
sha512=d8831d8a75fe43a7e8d16d2c0bb7d27f6d975133e17c5dd89ef7e575039c59d27c1ab74fbadcca81ddfbc0c74d1e46c35baba35ef825b36ac6c4e49d7a41d0c2

doc/src/riot.net/addr.ml.html

Source file addr.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
type 't raw_addr = string
type tcp_addr = [ `v4 | `v6 ] raw_addr
type stream_addr = [ `Tcp of tcp_addr * int ]

module Ipaddr = struct
  let to_unix : tcp_addr -> Unix.inet_addr = Unix.inet_addr_of_string
  let of_unix : Unix.inet_addr -> tcp_addr = Unix.string_of_inet_addr
end

let loopback : tcp_addr = "0.0.0.0"

let tcp host port =
  assert (String.length host > 0);
  `Tcp (host, port)

let to_unix addr =
  match addr with
  | `Tcp (host, port) ->
      (Unix.SOCK_STREAM, Unix.ADDR_INET (Ipaddr.to_unix host, port))

let to_domain addr = match addr with `Tcp (_host, _) -> Unix.PF_INET

let of_unix sockaddr =
  match sockaddr with
  | Unix.ADDR_INET (host, port) -> tcp (Ipaddr.of_unix host) port
  | Unix.ADDR_UNIX addr -> failwith ("unsupported unix addresses: " ^ addr)

let pp ppf (addr : stream_addr) =
  match addr with `Tcp (host, port) -> Format.fprintf ppf "%s:%d" host port
OCaml

Innovation. Community. Security.