I've recently needed to bind a swank server to a (VPN-only)
non-127.0.0.1 address. The attached patch adds an :address keyword arg
to swank:create-server which defaults to 127.0.0.1. It's fairly
straightforward, so I hope that slime committers will consider adding it.
--
Andreas Fuchs, (
http://%7Cim:asf@%7Cmailto:asf@)boinkor.net, antifuchs
Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.490
diff -u -r1.490 swank.lisp
--- swank.lisp 4 Jun 2007 16:17:17 -0000 1.490
+++ swank.lisp 16 Jul 2007 12:35:59 -0000
@@ -423,14 +423,17 @@
(defvar *coding-system* "iso-latin-1-unix")
+(defparameter *loopback-interface* "127.0.0.1")
+
(defun start-server (port-file &key (style *communication-style*)
(dont-close *dont-close*)
(coding-system *coding-system*))
"Start the server and write the listen port number to PORT-FILE.
This is the entry point for Emacs."
(flet ((start-server-aux ()
- (setup-server 0 (lambda (port)
- (announce-server-port port-file port))
+ (setup-server 0 *loopback-interface*
+ (lambda (port)
+ (announce-server-port port-file port))
style dont-close
(find-external-format-or-lose coding-system))))
(if (eq style :spawn)
@@ -440,22 +443,21 @@
(defun create-server (&key (port default-server-port)
(style *communication-style*)
(dont-close *dont-close*)
- (coding-system *coding-system*))
+ (coding-system *coding-system*)
+ (address *loopback-interface*))
"Start a SWANK server on PORT running in STYLE.
If DONT-CLOSE is true then the listen socket will accept multiple
connections, otherwise it will be closed after the first."
- (setup-server port #'simple-announce-function style dont-close
+ (setup-server port address #'simple-announce-function style dont-close
(find-external-format-or-lose coding-system)))
(defun find-external-format-or-lose (coding-system)
(or (find-external-format coding-system)
(error "Unsupported coding system: ~s" coding-system)))
-(defparameter *loopback-interface* "127.0.0.1")
-
-(defun setup-server (port announce-fn style dont-close external-format)
+(defun setup-server (port address announce-fn style dont-close external-format)
(declare (type function announce-fn))
- (let* ((socket (create-socket *loopback-interface* port))
+ (let* ((socket (create-socket address port))
(port (local-port socket)))
(funcall announce-fn port)
(flet ((serve ()