From 22c1e6dbe7cf74936e5ca29eadeff81312ccc506 Mon Sep 17 00:00:00 2001 From: buisson Date: Fri, 29 Apr 2005 09:35:43 +0000 Subject: Initial revision --- examples/ivyprobe.ml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/ivyprobe.ml (limited to 'examples/ivyprobe.ml') diff --git a/examples/ivyprobe.ml b/examples/ivyprobe.ml new file mode 100644 index 0000000..47bd2aa --- /dev/null +++ b/examples/ivyprobe.ml @@ -0,0 +1,40 @@ +(* $Id$ *) + +let print_message app message = + Printf.printf "%s sent" (Ivy.name_of_client app); + Array.iter (fun s -> Printf.printf " '%s'" s) message; + print_newline () + +let read = fun channel -> + let l = input_line channel in + Ivy.send l + +let watch_clients c e = + let dis = match e with Ivy.Connected -> "" | Ivy.Disconnected -> "dis" in + Printf.printf "%s %sconnected from %s\n" + (Ivy.name_of_client c) + dis + (Ivy.host_of_client c); + flush stdout + +let init = fun () -> + let regexp = ref "" + and name = ref "MLIVYPROBE" + and port = ref 2010 + and domain = ref "127.255.255.255" in + Arg.parse + [ "-b", Arg.Int (fun x -> port := x), "\tDefault is 2010, unused if IVYBUS is set"; + "-domain", Arg.String (fun x -> domain := x), "\tDefault is 127.255.255.255, unused if IVYBUS is set"; + "-n", Arg.String (fun s -> name := s), "\tDefault is MLIVYPROBE"] + (fun s -> regexp := s) + "Usage: "; + + let bus = + try Sys.getenv "IVYBUS" with + Not_found -> Printf.sprintf "%s:%d" !domain !port in + Ivy.init !name "READY" watch_clients; + Ivy.start bus; + + Printf.printf "\nEnd of file to stop\n\n"; flush stdout; + + ignore (Ivy.bind print_message !regexp) -- cgit v1.1