Well, it turns out that the following works, but it only prints the
"exchange" to stdout,
if the code is cut and pasted to the REPL but _not_ if run as .clj
script)...
(import
'(java.io IOException)
'(java.io OutputStream)
'(java.util Iterator)
'(java.util List)
'(java.util Set)
'(com.sun.net.httpserver Headers)
'(com.sun.net.httpserver HttpExchange)
'(com.sun.net.httpserver HttpHandler)
'(java.net InetSocketAddress)
'(java.util.concurrent Executors)
'(com.sun.net.httpserver HttpServer)
)
(def port 8888)
(let [server (. HttpServer create (new InetSocketAddress port) 0)
handler (proxy [HttpHandler] []
(handle [#^HttpExchange exchange]
(println exchange) ; this does not get printed if run
as script
(but it does if all of the code is pasted to the REPL)
(. exchange close)
))
]
(. server createContext "/" handler)
(. server setExecutor (. Executors newCachedThreadPool))
(. server start)
(print "server listening on port: ")(println port)
)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---