From ripley at stats.ox.ac.uk  Fri Jun  1 08:39:07 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 1 Jun 2007 07:39:07 +0100 (BST)
Subject: [Rd] Possible changes to connections
In-Reply-To: <465FBB8E.1040400@altk.com>
References: <Pine.LNX.4.64.0705301726400.11532@gannet.stats.ox.ac.uk>
	<465E7B0B.2080005@altk.com>
	<Pine.LNX.4.64.0705311534280.27499@gannet.stats.ox.ac.uk>
	<465FBB8E.1040400@altk.com>
Message-ID: <Pine.LNX.4.64.0706010735450.3308@gannet.stats.ox.ac.uk>

On Fri, 1 Jun 2007, mel wrote:

> Prof Brian Ripley a ?crit :
>
>>> I use getConnection().
>>> In the context in which I use it, the number of the connection is
>>> known a priori.
>>
>> I don't see how you can know it 'a priori': it is an implementation detail
>> (and since R itself uses connections, those details could easily change).
>
> (disclaimer : I don't claim its the best way to proceed)
>
> Before launching my app, the connections context is :
> > showConnections(all=TRUE)
>   description class      mode text   isopen   can read can write
> 0 "stdin"     "terminal" "r"  "text" "opened" "yes"    "no"
> 1 "stdout"    "terminal" "w"  "text" "opened" "no"     "yes"
> 2 "stderr"    "terminal" "w"  "text" "opened" "no"     "yes"
>
> So, the call to socketConnections() creates always (at least
> for all my experiments) a connection with number 3.
> Btw, if (socketConnections(...) != 3) the application simply
> don't launch.
> So, if the application runs, it's sure that this is with a
> connection number==3.
> That's why I say that "the number of the connection is known a priori".

You don't *know* that: it depends on how R internally numbers connections 
and what the startup code does.  That detail will almost certainly change.

> Of course, the connection number could also be retrieved eg using
> the description field.

For now, at least.

-- 
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] Possible changes to connections
Prof Brian Ripley