From simon.urbanek at r-project.org  Mon Mar  5 19:17:25 2007
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Mon, 5 Mar 2007 13:17:25 -0500
Subject: [Rd] non-blocking socketConnection
In-Reply-To: <617C6D86F3B78E44B37B5949CF1F8B0105942A4F@EXNJMB20.nam.nsroot.net>
References: <617C6D86F3B78E44B37B5949CF1F8B0105942A4F@EXNJMB20.nam.nsroot.net>
Message-ID: <739CEED1-ADDA-4D1F-A4D3-1222B43CF69E@r-project.org>


On Mar 5, 2007, at 12:05 PM, Chmielowski, Piotr2 [CAI] wrote:

> In an R session I have
>
>> c <-socketConnection("localhost", port=6011, blocking=F, server=T,
> open="w+")
>
> After I connect to the  server from, say, telnet
>
> % telnet localhost 6011
>
> the socketConnection returns and gives a valid c.
>
> My problem is as follows : I would expect something like
>
>> readLines(con=c, n=1)
>
>  to return immediately when reading from c non-blocking c, whether  
> there
> are any contents to be read or not. However, readLines only returns  
> when
> there is some input to be consumed, ie if in the telnet session I type
> foo followed by newline. In short, readLines seems to be blocking even
> though the connection is presumably non-blocking.
>
> FYI, A "file" connection does behave as expected, but I do need the
> socketConnection here. I am Running R 2.2.0-2.fc4, on Linux
> 2.6.11-1.1369.
>
> Any help would be greatly appreciated.
>

if (socketSelect(list(c),,0)) readLines(c, 1)

Cheers,
Simon



[Rd] non-blocking socketConnection
Simon Urbanek