summaryrefslogtreecommitdiff
path: root/ebus-racket/net-repl.rkt
diff options
context:
space:
mode:
authorRandom Hacker <random_hacker@xapek.org>2012-03-05 21:38:46 +0100
committerRandom Hacker <random_hacker@xapek.org>2012-03-05 21:38:46 +0100
commit312fc443d91af010051e278e03830aa5ffaa4c9c (patch)
treeb8e69640238c3cafdd7414ee32ebc77f00071576 /ebus-racket/net-repl.rkt
parent21d16fdf5d56b4776ca9ae6b7d2867f344e89a4a (diff)
downloadebus-alt-312fc443d91af010051e278e03830aa5ffaa4c9c.tar.gz
ebus-alt-312fc443d91af010051e278e03830aa5ffaa4c9c.zip
ebus-racket: net-repl POC
Diffstat (limited to 'ebus-racket/net-repl.rkt')
-rw-r--r--ebus-racket/net-repl.rkt34
1 files changed, 34 insertions, 0 deletions
diff --git a/ebus-racket/net-repl.rkt b/ebus-racket/net-repl.rkt
new file mode 100644
index 0000000..1d53807
--- /dev/null
+++ b/ebus-racket/net-repl.rkt
@@ -0,0 +1,34 @@
+#lang racket
+(require mzlib/thread)
+(require "db.rkt")
+
+(define-namespace-anchor a)
+(define ns (namespace-anchor->namespace a))
+
+(define (my-eval expr)
+ (eval expr ns))
+
+
+(define (run-tcp-repl namespace port)
+ (thread
+ (lambda ()
+ (run-server port
+ net-repl-connection
+ #f
+ (lambda (port-k max-allow-wait reuse?)
+ (tcp-listen port-k max-allow-wait reuse? "127.0.0.1"))
+ ))))
+
+ (define (net-repl-connection i o)
+ (let/ec exit
+ (parameterize ([current-input-port i]
+ [current-output-port o]
+ [current-error-port o]
+ [current-namespace ns])
+ (read-eval-print-loop))
+ (fprintf o "\nBye...\n")
+ (close-output-port o)))
+
+
+(define-namespace-anchor ns-anchor)
+(thread-wait (run-tcp-repl (namespace-anchor->namespace ns-anchor) 8890))