From: Adrien Nader <adrien@notk.org>
To: Thomas Braibant <thomas.braibant@gmail.com>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Unix file descriptors vs. in/out channels
Date: Mon, 18 Aug 2014 18:10:29 +0200 [thread overview]
Message-ID: <20140818161029.GA13445@notk.org> (raw)
In-Reply-To: <CAHR=VkwXynFAJm13MwKrsJNgx4HeW_LU03BQxqD4S7prG1A8Rw@mail.gmail.com>
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
next prev parent reply other threads:[~2014-08-18 16:10 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 [this message]
2014-08-18 16:15 ` Edouard Evangelisti
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=20140818161029.GA13445@notk.org \
--to=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