package tcpip
OCaml TCP/IP networking stack, used in MirageOS
Install
Dune Dependency
Authors
Maintainers
Sources
tcpip-v6.4.0.tbz
sha256=6e32bf540d291e9b7325cb3dd00df2f695533e009c46ea534d5518b9492c7348
sha512=2e9f9ca2eeac637599eb48e087b4632598539f1c76f9251758995c7eedeb723f8b951d557a2a53b85a58d50a04e68e15598581f88fca8997733e800fcfca422b
doc/src/tcpip.tcpv4-socket/tcp_socket.ml.html
Source file tcp_socket.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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
open Lwt type error = [ Mirage_protocols.Tcp.error | `Exn of exn ] type write_error = [ Mirage_protocols.Tcp.write_error | `Exn of exn ] let pp_error ppf = function | #Mirage_protocols.Tcp.error as e -> Mirage_protocols.Tcp.pp_error ppf e | `Exn e -> Fmt.exn ppf e let pp_write_error ppf = function | #Mirage_protocols.Tcp.write_error as e -> Mirage_protocols.Tcp.pp_write_error ppf e | `Exn e -> Fmt.exn ppf e let ignore_canceled = function | Lwt.Canceled -> Lwt.return_unit | exn -> raise exn let disconnect _ = return_unit let read fd = let buflen = 4096 in let buf = Cstruct.create buflen in Lwt.catch (fun () -> Lwt_cstruct.read fd buf >>= function | 0 -> return (Ok `Eof) | n when n = buflen -> return (Ok (`Data buf)) | n -> return @@ Ok (`Data (Cstruct.sub buf 0 n)) ) (fun exn -> return (Error (`Exn exn))) let rec write fd buf = Lwt.catch (fun () -> Lwt_cstruct.write fd buf >>= function | n when n = Cstruct.length buf -> return @@ Ok () | 0 -> return @@ Error `Closed | n -> write fd (Cstruct.sub buf n (Cstruct.length buf - n)) ) (function | Unix.Unix_error(Unix.EPIPE, _, _) -> return @@ Error `Closed | e -> return (Error (`Exn e))) let writev fd bufs = Lwt_list.fold_left_s (fun res buf -> match res with | Error _ as e -> return e | Ok () -> write fd buf ) (Ok ()) bufs (* TODO make nodelay a flow option *) let write_nodelay fd buf = write fd buf (* TODO make nodelay a flow option *) let writev_nodelay fd bufs = writev fd bufs let close fd = Lwt.catch (fun () -> Lwt_unix.close fd) (function | Unix.Unix_error (Unix.EBADF, _, _) -> Lwt.return_unit | e -> Lwt.fail e) let input _t ~src:_ ~dst:_ _buf = Lwt.return_unit
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>