Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] printable digest strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mattias Waldau <mattias.waldau@a...>
Subject: [Caml-list] Wserver: Values of global variables lost
I am trying to use wserver, and create a simple ocaml-based webserver.

I am using it locally, and I assumed that the global variables in my ocaml 
would be kept during the interaction with the user.

However, in the following program sofar is always ref "".

What have I misunderstood? How should I do? Have anyone else implemented a
minimal www-server?

My program that is compiled together with wserver, unix.cma and str.cma.
I use ocaml 3.01 on Redhat 7.1

/mattias

(* let _ = Wserver.f 2368 60 (fun _ s -> Printf.printf "You said: %s...\n" s) 
*)

let sofar = ref ""

let _ =
  let socket = 
    if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 2368 in
  Printf.printf "\nListening on socket %d\n" socket;
  flush stdout;
  Wserver.f socket 60 
    (fun _ s -> 
      Printf.printf "You said: %s...(%s)\n" 
	(Wserver.decode s)(Wserver.decode !sofar);
      sofar := !sofar ^ ", " ^ s;
      prerr_string !sofar; prerr_newline ()
    )

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr