Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: asmadeus77@gmail.com
To: "Berke Durak" <berke.durak@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] OCaml-ssl and input_string
Date: Tue, 6 May 2008 12:33:01 +0200	[thread overview]
Message-ID: <b79ece760805060333g49366b0ehe649235cc4a9cdf8@mail.gmail.com> (raw)
In-Reply-To: <b903a8570805060312ic0cffc6oacc317aaf363ced9@mail.gmail.com>

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 <berke.durak@gmail.com> 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
>


      reply	other threads:[~2008-05-06 10:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-05 19:54 asmadeus77
2008-05-06 10:12 ` Berke Durak
2008-05-06 10:33   ` asmadeus77 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b79ece760805060333g49366b0ehe649235cc4a9cdf8@mail.gmail.com \
    --to=asmadeus77@gmail.com \
    --cc=berke.durak@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox