[R] Socket question about isIncomplete and isOpen

ce zadig_1 at excite.com
Wed Oct 22 04:02:57 CEST 2014


I am trying to repeat socket example in ?socketConnection 

Server process :

con1 <- socketConnection(port = 6011, server = TRUE)
while(TRUE) { writeLines("aaaaa",con1 );  Sys.sleep(1) }

Client process

con2 <- socketConnection(Sys.info()["nodename"], port = 6011)
readLines(con2, n = 1 )
while(isIncomplete(con2)) 
{
        msg <- readLines(con2, n = 1 )
        if(!(is.character(msg) && length(msg) == 0)) { cat("msg = "); print(msg) }

}

I have two problems 

1- client side isIncomplete(con2) is always return FALSE and while loop ends 

2- client while loop works if I use isOpen(con2) but  if server dies  client loop doesn't exit ?



More information about the R-help mailing list