made a weird deck a long time ago about this kinda stuff

This commit is contained in:
cqc
2023-08-26 15:21:28 -05:00
parent 60c83c608a
commit ee550301e9
7 changed files with 19 additions and 0 deletions

17
doc/deck_example.ml Normal file
View File

@ -0,0 +1,17 @@
let rec copy_blocks buffer r w =
match%lwt Lwt_io.read_into r buffer 0 (Bytes.length buffer) with
| 0 -> Lwt.return_unit
| bytes_read ->
let%lwt () = Lwt_io.write_from_exactly w buffer 0 bytes_read in
copy_blocks buffer r w
let run () =
((let%lwt server =
Lwt_io.establish_server (Lwt_unix.ADDR_INET (Unix.inet_addr_any, 8765))
(fun (r, w) ->
let buffer = Bytes.create (16 * 1024) in
copy_blocks buffer r w)
in
Lwt.return server) : Lwt_io.server Lwt.t) |> ignore
let () = Lwt_main.run run ();