diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2012-09-08 19:24:10 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2012-09-08 19:24:10 +0200 |
commit | 977335378247e8c7df0594fc300cb82c4ce6bbc7 (patch) | |
tree | 35c9292bdf372cc596f3e7de9331a667a526a212 | |
parent | 97f2fb5b47aaeec00cdcd1c6082e95c907eb3f62 (diff) | |
download | geiser-chez-977335378247e8c7df0594fc300cb82c4ce6bbc7.tar.gz geiser-chez-977335378247e8c7df0594fc300cb82c4ce6bbc7.tar.bz2 |
Racket: new option to specify network interface for REPL server
In geiser-racket.sh, there's the new option -n, which uses a new
hostname argument accepted by geiser/user's start-geiser function.
-rwxr-xr-x | bin/geiser-racket.sh | 4 | ||||
-rw-r--r-- | doc/repl.texi | 11 | ||||
-rw-r--r-- | scheme/racket/geiser/user.rkt | 8 |
3 files changed, 13 insertions, 10 deletions
diff --git a/bin/geiser-racket.sh b/bin/geiser-racket.sh index 5fdfffe..b3d96e9 100755 --- a/bin/geiser-racket.sh +++ b/bin/geiser-racket.sh @@ -9,11 +9,13 @@ exec racket -i -S "$top/racket" -l errortrace -cu "$0" ${1+"$@"} (require (lib "cmdline.rkt")) (define port (make-parameter 0)) +(define host (make-parameter #f (lambda (h) (and (string? h) h)))) (command-line "run-racket.sh" (current-command-line-arguments) (once-each + (("-n" "--hostname") n "Network hostname, or #f for all interfaces" (host n)) (("-p" "--port") p "Geiser server port" (port (string->number p))))) (printf "Geiser server running at port ~a~%" - ((dynamic-require 'geiser/server 'start-geiser) (port))) + ((dynamic-require 'geiser/server 'start-geiser) (port) (host))) diff --git a/doc/repl.texi b/doc/repl.texi index 560f3eb..dcc1bd0 100644 --- a/doc/repl.texi +++ b/doc/repl.texi @@ -75,11 +75,12 @@ In Racket, you have to use the REPL server that comes with Geiser. To that end, put Geiser's Racket @file{scheme} directory in Racket's collection search path and invoke @code{start-geiser} (a procedure in the module @code{geiser/server}) somewhere in your program, passing it -the desired port. This procedure will start the REPL server in a -separate thread. For an example of how to do that, see the script -@file{bin/geiser-racket.sh} in the source distribution, or, if you've -compiled Geiser, @file{bin/geiser-racket-noinst} in the build directory, -or, if you've installed Geiser, @file{geiser-racket} in +the desired port and, if desired, network interface name. This +procedure will start the REPL server in a separate thread. For an +example of how to do that, see the script @file{bin/geiser-racket.sh} in +the source distribution, or, if you've compiled Geiser, +@file{bin/geiser-racket-noinst} in the build directory, or, if you've +installed Geiser, @file{geiser-racket} in @file{<installation-prefix>/bin}. These scripts start a new interactive Racket that is also running a REPL server (they also load the errortrace library to provide better diagnostics, but that's not strictly needed). diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt index e9540b0..f383a46 100644 --- a/scheme/racket/geiser/user.rkt +++ b/scheme/racket/geiser/user.rkt @@ -110,18 +110,18 @@ (define server-channel (make-channel)) -(define (run-geiser-server port enforce-module-constants) +(define (run-geiser-server port enforce-module-constants (hostname #f)) (run-server port (lambda (in out) (run-geiser-repl in out enforce-module-constants)) #f void (lambda (p _ __) - (let ([lsner (tcp-listen p)]) + (let ([lsner (tcp-listen p 4 #f hostname)]) (let-values ([(_ p __ ___) (tcp-addresses lsner #t)]) (channel-put server-channel p) lsner))))) -(define (start-geiser (port 0) (enforce-module-constants #f)) - (thread (lambda () (run-geiser-server port enforce-module-constants))) +(define (start-geiser (port 0) (hostname #f) (enforce-module-constants #f)) + (thread (lambda () (run-geiser-server port enforce-module-constants hostname))) (channel-get server-channel)) |