[R] detecting EOF on connection?
Andy Jacobson
andyj at splash.princeton.edu
Sun Aug 24 20:52:01 CEST 2003
>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
Andy> Is there an easy way of determining whether one has reached the
Andy> end-of-file when reading a connection? I am reading a binary
Andy> file and I would like to know when the read fails.
BDR> When the readBin gives a 0-length result. See the help file.
Thank you for your response. I may have a platform- and
compiler-dependent bug to report.
In my case readBin apparently does not return an object of zero
length when reading past EOF. This is on Mac OS X, for which
recent gcc libraries have allegedly had a stream reading error
that resulted in incorrect stream state at EOF. This is very
definitely the case for me with octave (www.octave.org) built on
this machine. I only know about this bug second-hand, and I'd
appreciate a pointer to more information from anyone who knows
more about it. I've tested the case on a Linux machine and
the problem goes away: readBin at EOF returns an object of zero
length there.
This bug is supposedly fixed for gcc-3.3 on OS X, but we users of
fink are in a catch-22 as we are strongly advised not to upgrade
gcc past 3.1. (see http://fink.sourceforge.net). I've been
wondering how R-from-fink got around this problem.
Reproducing the bug is problematic, as it only happens when I am
reading a fairly large (0.6 MB) binary file.
-Andy
--
Andy Jacobson
andyj at splash.princeton.edu
Program in Atmospheric and Oceanic Sciences
Sayre Hall, Forrestal Campus
Princeton University
PO Box CN710 Princeton, NJ 08544-0710 USA
Tel: 609/258-5260 Fax: 609/258-2850
More information about the R-help
mailing list