(index ("nrepl" 0) ("nrepl-loop" 1248))
(def (sig (procedure " (nrepl port [spawn])" (id nrepl))) (p "Listen to TCP port " (tt "port") " number and (blockingly) wait for incoming connections.  " (tt "(spawn)") " is called for each incomming connection without arguments where " (tt "current-input-port") ", " (tt "current-output-port") " and " (tt "current-error-port") " are bound to the TCP connection.") (p "You can use " (tt "spawn") ", for example, for authentication:") (highlight scheme "    \n(nrepl 1234\n       (lambda ()\n         (thread-start! ;; otherwise accept-loop will be blocked\n          (lambda ()\n            (display \";; please enter an accept token: \")\n            (define token (read-line))\n            (if (equal? token \"abc\")\n                (nrepl-loop)\n                (begin (print \";; access denied\")\n                       (close-input-port (current-input-port))\n                       (close-output-port (current-output-port))\n               (close-output-port (current-error-port))))))))") (p "blockquoteYou can use " (tt "tcp-addresses") " and " (tt "tcp-port-numbers") " to find out where the new session is coming from.") (p (tt "nrepl") " will loop for accepting incomming connections unless " (tt "spawn") " returns " (tt "#f") "."))
(def (sig (procedure " (nrepl-loop #!key eval read print writeln)" (id nrepl-loop))) (p "Start a standard REPL-loop: print the prompt, read an s-expression, evaluate the expression, print the result and repeat. Exceptions are reported and data is flushed. This can be used inside the optionally supplied " (tt "spawn") "-procedure above."))
