if (FALSE) # Need internet connection
mysocket <- socketConnection( host = "pbil.univ-lyon1.fr",
port = 5558, server = FALSE, blocking = TRUE)
readLines(mysocket, n = 1) # OK acnuc socket started
acnucopen("emblTP", socket = mysocket) -> res
expected <- c("EMBL", "14138095", "236401", "1186228", "8",
"16", "40", "40", "20", "20", "40", "60", "504")
stopifnot(all(unlist(res) == expected))
tryalreadyopen <- try(acnucopen("emblTP", socket = mysocket))
stopifnot(inherits(tryalreadyopen, "try-error"))
# Need a fresh socket because acnucopen() close it if error:
mysocket <- socketConnection( host = "pbil.univ-lyon1.fr",
port = 5558, server = FALSE, blocking = TRUE)
tryoff <- try(acnucopen("off", socket = mysocket))
stopifnot(inherits(tryoff, "try-error"))
mysocket <- socketConnection( host = "pbil.univ-lyon1.fr",
port = 5558, server = FALSE, blocking = TRUE)
tryinexistent <- try(acnucopen("tagadatagadatsointsoin", socket = mysocket))
stopifnot(inherits(tryinexistent, "try-error"))
mysocket <- socketConnection( host = "pbil.univ-lyon1.fr",
port = 5558, server = FALSE, blocking = TRUE)
trycloseunopened <- try(acnucclose(mysocket))
stopifnot(inherits(trycloseunopened, "try-error"))
Run the code above in your browser using DataLab