X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=blobdiff_plain;f=swank.R;fp=swank.R;h=20311847afef86a62468a50c58b0f1962cc7dc9b;hp=dea28cf99f2f72cec6ccadc13d1266b88b571c78;hb=b5398e520cf5ce15811f323f3d48b68804b335c9;hpb=a46793d3e275c91add4a5235bf1d812668714629 diff --git a/swank.R b/swank.R index dea28cf..2031184 100644 --- a/swank.R +++ b/swank.R @@ -33,9 +33,10 @@ acceptConnections <- function(port, portFile) { cat(port, file=f) close(f) } + ## FIXME: maybe we should support dontClose here? s <- socketConnection(host="localhost", server=TRUE, port=port, open="r+b") on.exit(close(s)) - serve(s) + tryCatch(serve(s), endOfFile=function(c) NULL) } serve <- function(io) { @@ -145,6 +146,11 @@ readPacket <- function(io) { readChunk <- function(io, len) { buffer <- readChar(io, len) + if(length(buffer) == 0) { + condition <- simpleCondition("End of file on io") + class(condition) <- c("endOfFile", class(condition)) + signalCondition(condition) + } if(nchar(buffer) != len) { stop("short read in readChunk") }