clojure.core.server exposes the Clojure environment through sockets, letting remote processes or people send Clojure requests and receive evaluated results. Its default service is a socket-based variant of the console REPL. section 22.7
Configure a server with a map passed to start-server:
- :port and :name are required; :address defaults to 127.0.0.1. section 22.7
- :accept selects the fully qualified request handler, while :args supplies optional handler arguments. section 22.7
- :bind-err controls whether standard error is sent through the socket, and daemon options control JVM and client-thread lifetime. section 22.7
Start and use a remote REPL
Require the namespace and start a named server with (server/start-server {:name "repl1" :port 8787 :accept clojure.core.server/repl}). A client can connect with telnet 127.0.0.1 8788, evaluate (+ 1 1), and receive 2. Stop one server with (server/stop-server "repl2") or stop all servers with (server/stop-servers). section 22.7
(require '[clojure.core.server :as server]) ; #1
(server/start-server ; #2
{:name "repl1" :port 8787 :accept clojure.core.server/repl})
;; #object["ServerSocket[addr=localhost/127.0.0.1,localport=8787]"]
Inspect the minimal start-server form and its returned ServerSocket representation. section 22.7
