[Rd] non-blocking socketConnection
simon.urbanek at r-project.org
Mon Mar 5 19:17:25 CET 2007
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,
> 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
> are any contents to be read or not. However, readLines only returns
> 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
> Any help would be greatly appreciated.
if (socketSelect(list(c),,0)) readLines(c, 1)
More information about the R-devel