;; A Simple server that dumps the input stream to the output stream.
;; In this example, the create-server function is called with two
;; arguments, a port number and an anonymous function. The input
;; and output stream arguments passed to the anonymous function are
;; bound to the standard input and output respectively.
(use 'clojure.contrib.server-socket)
(import '(java.io BufferedReader InputStreamReader PrintWriter))
user=> (create-server
8080
(fn [in out]
(binding
[*in* (BufferedReader. (InputStreamReader. in))
*out* (PrintWriter. out)]
(loop []
(println (read-line))
(recur)))))
{:server-socket #<ServerSocket ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=8080]>, :connections #<Ref@73f17a73: #{}>}
;; A Simple server that dumps the input stream to the output stream.
;; In this example, the create-server function is called with two
;; arguments, a port number and an anonymous function. The input
;; and output stream arguments passed to the anonymous function are
;; bound to the standard input and output respectively.
(use 'clojure.contrib.server-socket)
(import '(java.io BufferedReader InputStreamReader PrintWriter))
user=> (create-server
8080
(fn [in out]
(binding
[*in* (BufferedReader. (InputStreamReader. in))
*out* (PrintWriter. out)]
(loop []
(println (read-line))
(recur)))))
{:server-socket #<ServerSocket ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=8080]>, :connections #<Ref@73f17a73: #{}>}