ClojureDocs

Namespaces

clojure.core.server

Socket server support

clojure.core.server contains functions to expose the Clojure environment through a socket connection and across network boundaries. If the property -Dclojure.server.repl="{:port 8881 :accept clojure.core.server/repl}" is present when the JDK starts, Clojure will start the related socket server (or more than one) on the specified port. The API in the namespace allows to do this programmatically.

Vars in clojure.core.server

*^%

*session*
no doc

i

io-prepl
prepl bound to *in* and *out*, suitable for use with e.g. server/repl (socket-repl). :ret and :tap vals will be processed by valf, a fn of one argument or a symbol naming same (default pr-str) Alpha, subject to change.

p

prepl
a REPL with structured output (for programs) reads forms to eval from in-reader (a LineNumberingPushbackReader) Closing the input or passing the form :repl/quit will cause it to return Calls out-fn with data, one of: {:tag :ret :val val ;;eval result :ns ns-name-string :ms long ;;eval time in milliseconds :form string ;;iff successfully read :clojure.error/phase (:execution et al per clojure.main/ex-triage) ;;iff error occurred } {:tag :out :val string} ;chars from during-eval *out* {:tag :err :val string} ;chars from during-eval *err* {:tag :tap :val val} ;values from tap> You might get more than one :out or :err per eval, but exactly one :ret tap output can happen at any time (i.e. between evals) If during eval an attempt is made to read *in* it will read from in-reader unless :stdin is supplied Alpha, subject to change.

r

remote-prepl
Implements a prepl on in-reader and out-fn by forwarding to a remote [io-]prepl over a socket. Messages will be read by readf, a fn of a LineNumberingPushbackReader and EOF value or a symbol naming same (default #(read %1 false %2)), :ret and :tap vals will be processed by valf, a fn of one argument or a symbol naming same (default read-string). If that function throws, :val will be unprocessed. Alpha, subject to change.
repl
REPL with predefined hooks for attachable socket server.
repl-init
Initialize repl in user namespace and make standard repl requires.
repl-read
Enhanced :read hook for repl supporting :repl/quit.

s

start-server
Start a socket server given the specified opts: :address Host or address, string, defaults to loopback address :port Port, integer, required :name Name, required :accept Namespaced symbol of the accept function to invoke, required :args Vector of args to pass to accept function :bind-err Bind *err* to socket out stream?, defaults to true :server-daemon Is server thread a daemon?, defaults to true :client-daemon Are client threads daemons?, defaults to true Returns server socket.
start-servers
Start all servers specified in the system properties.
stop-server
Stop server with name or use the server-name from *session* if none supplied. Returns true if server stopped successfully, nil if not found, or throws if there is an error closing the socket.
stop-servers
Stop all servers ignores all errors, and returns nil.