technomancy/swank-clojure — Issue #68: clojure-jack-in : error in process filter: open-network-stream: make client process failed: Connection refused
Author: ashee
Created: 2011-10-11 13:42:38+00:00
State: open

I think I found a bug in clojure-jack-in. leiningen.jack-in/jack-in passes "localhost" to swank.swank/start-server which ultimately calls java.net.InetAddress/getByName("localhost") which does not return the loopback interface. But slime-connect expects to connect on the loopback. I changed the call to java.net.InetAddress/getByName(nil) and it seems to work now.

Here's the patch

From 95d561aa5cd1a30b8aba4a95a7675bbf2652627d Mon Sep 17 00:00:00 2001
From: Amitava Shee
Date: Tue, 11 Oct 2011 09:25:40 -0400
Subject: [PATCH] fixed clojure-jack-in issue due to InetAddress.getByName not
returning loopback

---
src/swank/util/net/sockets.clj | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/swank/util/net/sockets.clj b/src/swank/util/net/sockets.clj
index 1c45ff1..af31b21 100644
--- a/src/swank/util/net/sockets.clj
+++ b/src/swank/util/net/sockets.clj
@@ -24,7 +24,9 @@
(when-let [host (options :host)]
(if (instance? InetAddress host)
host
- (InetAddress/getByName host))))))
+ (if (= host "localhost")
+ (InetAddress/getByName nil)
+ (InetAddress/getByName host)))))))

(defn start-server-socket!
"Given a `server-socket' (java.net.ServerSocket), call
--
1.7.5.2