From: Christophe Rhodes Date: Wed, 6 Apr 2011 08:13:30 +0000 (+0100) Subject: enough support for emacs/slim to start swank for itself X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=commitdiff_plain;h=d4dba776122f9750b3e0d2c1ba7d1f8ec127642a enough support for emacs/slim to start swank for itself There's a race condition, I think, in between writing the socket port and running the socket server; it might be as simple as reordering the writing and the socket opening, but strange things happened once when I did that. --- diff --git a/swank.R b/swank.R index 8c5bafd..ebf580c 100644 --- 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)