From ripley at stats.ox.ac.uk  Fri Apr  8 18:19:42 2011
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 8 Apr 2011 17:19:42 +0100 (BST)
Subject: [Rd] Invalid connection after closing?
In-Reply-To: <BANLkTikazPA34K0BjONF5tBv_0DAkbMMfQ@mail.gmail.com>
References: <BANLkTin3MO-f_dLz4RnCRnj_EXP-Bd=c3Q@mail.gmail.com>
	<4D9F252A.3020702@gmail.com>
	<BANLkTikazPA34K0BjONF5tBv_0DAkbMMfQ@mail.gmail.com>
Message-ID: <alpine.LFD.2.02.1104081717210.12610@gannet.stats.ox.ac.uk>

On Fri, 8 Apr 2011, Joris Meys wrote:

> Thx for the information. I read it, but I wasn't sure what was going
> on inside.

Then perhaps you needed to do your homework: the references on the 
help page would have explained it to you.

> Is there a way to close a connection without destroying it?
> Guess not, but you never know...

Not from R code.

>
> Cheers
> Joris
>
> On Fri, Apr 8, 2011 at 5:09 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>> On 08/04/2011 10:56 AM, Joris Meys wrote:
>>>
>>> Dear all,
>>>
>>> I do not completely understand following behaviour :
>>>
>>>> ?con<- file("test.txt")
>>>> ?isOpen(con)
>>> [1] FALSE
>>>> ?open(con)
>>>> ?isOpen(con)
>>> [1] TRUE
>>>> ?close(con)
>>>> ?isOpen(con)
>>> Error in isOpen(con) : invalid connection
>>>> ?str(con)
>>> Classes 'file', 'connection' ?atomic [1:1] 3
>>> ? ..- attr(*, "conn_id")=<externalptr>
>>>
>>> Why do I get an error, indicating an invalid connection, after I
>>> closed a connection? Is this to be expected?
>>
>> Quoting ?close: " ?close? closes and destroys a connection. " In the current
>> implementation, connections are a finite resource, and you need to be able
>> to get rid of them when you are done. close(con) is the way to do that. If
>> you want to re-open it, you need to remember the filename (or extract it
>> before calling close()), and issue another call to file().
>>
>> Duncan Murdoch
>>
>
>
>
> -- 
> Joris Meys
> Statistical consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] Invalid connection after closing?
Prof Brian Ripley