Christophe Weblog Wiki Code Publications Music
enough support for emacs/slim to start swank for itself
[swankr.git] / swank.R
diff --git a/swank.R b/swank.R
index 8c5bafdccd1d5d198f534d971db0455fba703095..ebf580c510af115b66c703f4557797917b72c27e 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -18,10 +18,15 @@ swank <- function(port=4005) {
 }
 
 startSwank <- function(portFile) {
-  acceptConnections(FALSE, portFile)
+  acceptConnections(4005, portFile)
 }
 
 acceptConnections <- function(port, portFile) {
+  if(portFile != FALSE) {
+    f <- file(portFile, open="w+")
+    cat(port, file=f)
+    close(f)
+  }
   s <- socketConnection(host="localhost", server=TRUE, port=port, open="r+b")
   on.exit(close(s))
   serve(s)