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 LAA04273; Fri, 13 Sep 2002 11:01:04 +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 LAA03891 for ; Fri, 13 Sep 2002 11:01:03 +0200 (MET DST) Received: from athlon.baretta.com (host19-68.pool80116.interbusiness.it [80.116.68.19]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g8D912928957 for ; Fri, 13 Sep 2002 11:01:02 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 27B3E273B9; Fri, 13 Sep 2002 11:10:01 +0200 (CEST) Message-ID: <3D81AB68.5010606@baretta.com> Date: Fri, 13 Sep 2002 11:10:00 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Richard Lyman , Ocaml Subject: Re: [Caml-list] Setting the EOL character.... References: <4D5CA086.356E9A2F.00958B05@netscape.net> <000401c25ace$6896c7b0$0a00a8c0@stone> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Richard Lyman wrote: > Ok... > > That doesn't look too bad - and I think I almost understand it. : ) > > ... so then - there's no OCaml concept of a global EOL variable, or method > that deals with reading in from a stream until the EOL?? > > I was hoping more for something along the lines of - > > (start pseudocode) > > myStream = Unix.accepted_socket_stream > while(true){ > a_line = myStream.read_until("\000") > deal_with_line(a_line) > } > > (end pseudocode) > > Thanks for your thoughts! > > -Rich How about the following: let process_line out_channel line = .... in let read_until_null in_channel out_channel = Scanf.fscanf in_channel "[^\000]\000" (process_line out_channel) in let process_request in_channel out_channel = try while true do read_until_null in_channel out_channel done with End_of_file -> () let sockaddr = in Unix.establish_server process_request sockaddr Nonetheless, let me suggest that you look into ocamllex and ocamlyacc--lexer and parser generators respectively. They are probably your best choice for lexing and parsing the input stream, no matter how weird its structure. Alex ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners