From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=NO_REAL_NAME autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 05409BBCA for ; Tue, 6 May 2008 12:33:03 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkcBAPbQH0jRVciuc2dsb2JhbACQe34BDAMEBAkPBZQfhSQ X-IronPort-AV: E=Sophos;i="4.27,443,1204498800"; d="scan'208";a="12299843" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 May 2008 12:33:03 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m46AX3oc030368 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 6 May 2008 12:33:03 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkcBAPbQH0jRVciuc2dsb2JhbACQe34BDAMEBAkPBZQfhSQ X-IronPort-AV: E=Sophos;i="4.27,443,1204498800"; d="scan'208";a="12299841" Received: from wf-out-1314.google.com ([209.85.200.174]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 May 2008 12:33:02 +0200 Received: by wf-out-1314.google.com with SMTP id 25so1588494wfa.0 for ; Tue, 06 May 2008 03:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=RKTU3oCLm95GztAskxY17vJBmr+Ddam9yuIyOiWIybE=; b=g5lkh39I9fiwYJ+2V/3HDLbxWFxFO4qmvh+SrHJcgQEvGhPX8UCrGtUoCQFOyd07uUwmC2tL4dfK4LS/UckyFtC4LHYIE08AwQkJ24l9G+JgfWQoX3r4+YL2WcXiC+TfupEe/HgPVuEnxJAYyrSQToEdlp4joxAgoDHMG6hXrAQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kQsArNOYnIgVqnYDPWMiTuqzYoNA306E3KosRS8xaDeGfY8/5e8HEscy9k4j6WP1wm+9nr7nN/K7TsvzbqTWKOtC2yM2RQYSzdYWsEblBndsKwzCzapLTzuNZA4lM117LObkm5WLb3A420zt5DXMh3cXA+MqDXwNjEKsGfaslvk= Received: by 10.142.69.16 with SMTP id r16mr254148wfa.268.1210069981606; Tue, 06 May 2008 03:33:01 -0700 (PDT) Received: by 10.143.174.3 with HTTP; Tue, 6 May 2008 03:33:01 -0700 (PDT) Message-ID: Date: Tue, 6 May 2008 12:33:01 +0200 From: asmadeus77@gmail.com To: "Berke Durak" Subject: Re: [Caml-list] OCaml-ssl and input_string Cc: caml-list In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Miltered: at concorde with ID 482033DF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; buffer:01 scanf:01 sscanf:01 scanf:01 buffer:01 berke:01 durak:01 berke:01 durak:01 non-blocking:01 semantics:01 sockets:01 wrote:01 parsing:01 caml-list:01 Hello, Well, I don't know how it should work, but from what I've seen, it seems that its read function will wait untill there is something to read if nothing is available. Anyway, I have written an input_line (read character by character untill a '\n') function which allows me to stop as soon as I can match the begining of the line read with a pattern I get on the greeting. That will work untill someone tries to send me funny mails with lots of line feeds followed by weird 8-10 characters strings followed by a space, I guess it's safe enough. I just don't feel confident writing things such as : let ret = Buffer.create 1024 in let str = ref (input_line s) in while try Scanf.sscanf !str (Scanf.format_from_string (id^ " ") "") (fun _ -> ()) (); false with _-> true do Buffer.add_string ret !str; str:=input_line s done; Buffer.contents ret On 5/6/08, Berke Durak wrote: > Hello, > > From what I've inferred from ocaml-ssl's documentation, its "read" function > has Unix-like non-blocking > semantics. > > This means that read returns the number of bytes available, not the number > of bytes requested. > > Hence you need an extra buffering/parsing layer on top of SSL sockets. > However you are using > IMAP, which is line-oriented, I guess Ssl.input_string should do what you > want. > -- > Berke >