caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Edouard Evangelisti <edouard.evangelisti@slcu.cam.ac.uk>
To: Adrien Nader <adrien@notk.org>
Cc: Thomas Braibant <thomas.braibant@gmail.com>,
	OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Unix file descriptors vs. in/out channels
Date: Mon, 18 Aug 2014 17:15:42 +0100	[thread overview]
Message-ID: <CAMCFErTDP57pmZZQiHOyhhGGaMirwLpO+7_2iHvbW+KEC2m3Xw@mail.gmail.com> (raw)
In-Reply-To: <20140818161029.GA13445@notk.org>

[-- Attachment #1: Type: text/plain, Size: 1863 bytes --]

​​Dear Paolo and Anders,

Thank you for your messages. I tried to use Paolo's code and the exception
Timeout was raised. I was not able to read char by char without O_NONBLOCK
: the program is just waiting forever for something to read.

I was able to retrieve some data using Unix.in_channel_of_descr, but the
data are not transmitted synchronously, which is required in my case. Thus,
I will probably rewrite this part in C using the same strategy and see if
it works. I cannot understand why this strategy works for HyperTerminal and
not for me with the same material.

Thank you again.

Edouard


2014-08-18 17:10 GMT+01:00 Adrien Nader <adrien@notk.org>:

> Hi,
>
> You cannot safely mix buffered (in/out_channel) and un-buffered
> (file_descr) uses of the same underlying resource.
>
> IIRC an in_channel or out_channel has a buffer in OCaml memory.
> If you close the underlying file_descr of an out_channel with
> functions operating on file desriptors directly, it is possible that
> some data will still be buffered.
> If you read alternatively through file_descr and in_channel, you might
> skip some data if reading with the in_channel reads more than just "n
> chars" (it could read 4K for instance, I'm not completely sure).
>
> As for using in/out_channel_of_descr more than once, I don't know
> offhand: if it creates new buffers each time (likely), it will be an
> issue.
>
> --
> Adrien Nader
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
Edouard Evangelisti
Post doctoral Research Associate
Sainsbury Laboratory, Cambridge University (SLCU)
Bateman Street
Cambridge CB2 1LR (United Kingdom)

[-- Attachment #2: Type: text/html, Size: 3087 bytes --]

  reply	other threads:[~2014-08-18 16:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 14:42 Thomas Braibant
2014-08-18 16:10 ` Adrien Nader
2014-08-18 16:15   ` Edouard Evangelisti [this message]
2014-08-18 16:29   ` Thomas Braibant
2014-08-18 16:33 ` Xavier Leroy
2014-08-18 16:52   ` Thomas Braibant
2014-08-18 16:57     ` Xavier Leroy
2014-08-18 17:18       ` Thomas Braibant
2014-08-18 17:55         ` David Sheets

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=CAMCFErTDP57pmZZQiHOyhhGGaMirwLpO+7_2iHvbW+KEC2m3Xw@mail.gmail.com \
    --to=edouard.evangelisti@slcu.cam.ac.uk \
    --cc=adrien@notk.org \
    --cc=caml-list@inria.fr \
    --cc=thomas.braibant@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).