Comment detail

echoクライアント (Nested Flatten)

ocamlfind c -package unix -linkpkg -o echoc echoc.ml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
open Unix

let conn host port =
  let hostent = gethostbyname host in
  open_connection (ADDR_INET(hostent.h_addr_list.(0), port))

let main () =
  let (ich, och) = conn Sys.argv.(1) (int_of_string Sys.argv.(2)) in
  let rec loop () =
    let str = read_line () in
    Printf.fprintf och "%s\r\n" str; flush och;
    print_endline (input_line ich);
    loop () in
  loop ()

let _ = main ()

Index

Feed

Other

Link

Pathtraq

loading...