From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA10154; Sun, 6 May 2001 20:55:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA10173 for ; Sun, 6 May 2001 20:55:54 +0200 (MET DST) Received: from tor.abc.se (ns.abc.se [195.17.72.11]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f46ItrD12998 for ; Sun, 6 May 2001 20:55:54 +0200 (MET DST) Received: from fforum.se (dialup-55 [195.17.73.55]) by tor.abc.se (8.9.3+Sun/8.9.3) with SMTP id UAA21085 for ; Sun, 6 May 2001 20:55:52 +0200 (MET DST) Content-Type: text/plain; charset="iso-8859-1" From: Mattias Waldau Subject: [Caml-list] Wserver: Values of global variables lost Date: Sun, 6 May 2001 20:56:48 +0200 X-Mailer: KMail [version 1.2] References: <20010503153234.A28259@caddr.com> <4.3.2.7.2.20010504125129.00e25990@shell16.ba.best.com> In-Reply-To: <4.3.2.7.2.20010504125129.00e25990@shell16.ba.best.com> MIME-Version: 1.0 Message-Id: <01050620563901.11893@fforum.se> Content-Transfer-Encoding: 8bit To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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