Skip to content

Instantly share code, notes, and snippets.

@brodieG
Last active August 22, 2016 01:44
Show Gist options
  • Save brodieG/8eaccf0e1bb7cb2f60f1ecfcd26b473c to your computer and use it in GitHub Desktop.
Save brodieG/8eaccf0e1bb7cb2f60f1ecfcd26b473c to your computer and use it in GitHub Desktop.
Illustrate Connection Issues
f1 <- tempfile()
f2 <- tempfile()
cat("hello\n", file=f1)
cat("goodbye\n", file=f2)
con1 <- file(f1)
open(con1)
getAllConnections()
close(con1)
con2 <- file(f2)
open(con2)
# Doesn't work
con1 %in% getAllConnections()
## [1] TRUE
# This check may make it work, in addition to checking getAllConnections()
f1 %in% showConnections()[, 1]
## [1] FALSE
f2 %in% showConnections()[, 1]
## [1] TRUE
@brodieG
Copy link
Author

brodieG commented Aug 22, 2016

The particularly terrible thing in all this is that con1 ends up pointing to the same place as con2 ... for example isOpen(con1) returns TRUE. Internals shouldn't re-use connection ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment