-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathpipe_hello_world.ml
More file actions
23 lines (20 loc) · 769 Bytes
/
pipe_hello_world.ml
File metadata and controls
23 lines (20 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let () =
let client = Luv.Pipe.init () |> Result.get_ok in
Luv.Pipe.connect client "echo-pipe" begin function
| Error e ->
Printf.eprintf "Connect error: %s\n" (Luv.Error.strerror e)
| Ok () ->
let message = Luv.Buffer.from_string "Hello, world!" in
Luv.Stream.write client [message] (fun _result _bytes_written ->
Luv.Stream.shutdown client ignore);
Luv.Stream.read_start client begin function
| Error `EOF ->
Luv.Handle.close client ignore
| Error e ->
Printf.eprintf "Read error: %s\n" (Luv.Error.strerror e);
Luv.Handle.close client ignore
| Ok response ->
print_endline (Luv.Buffer.to_string response)
end
end;
ignore (Luv.Loop.run () : bool)