Programs often want to provide REPLs to users in contexts when a) network communication is desired, b) capturing stdio is difficult, or c) when more than one REPL session is desired. In addition, tools that want to support REPLs and simultaneous conversations with the host are difficult with a single stdio REPL as currently provided by Clojure.
Tooling and users often need to enable a REPL on a program without changing the program, e.g. without asking author or program to include code to start a REPL host of some sort. Thus a solution must be externally and declaratively configured (no user code changes). A REPL is just a special case of a socket service. Rather than provide a socket server REPL, provide a built-in socket server that composes with the existing repl function.
For design background, see: http://dev.clojure.org/display/design/Socket+Server+REPL
Start a socket server by supplying an extra system property (classpath and clojure.main here, but this would generally be starting your own app instead - we won't use the repl it starts):
where options are:
address = host or address, defaults to loopback
port = port, required
accept = namespaced function to invoke on socket accept, required
args = sequential collection of args to pass to accept
bind-err = defaults to true, binds err to out stream
server-daemon = defaults to true, socket server thread doesn't block exit
client-daemon = defaults to true, socket client threads don't block exit
Run a repl client using telnet: