Skip to content

Instantly share code, notes, and snippets.

@ruseel
Created September 10, 2014 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruseel/97c8a7cf4804363c0246 to your computer and use it in GitHub Desktop.
Save ruseel/97c8a7cf4804363c0246 to your computer and use it in GitHub Desktop.
echo-server.clj
(ns w.clj
(:require [clojure.java.io :as io])
(:import [java.net ServerSocket]
[java.lang Integer])
(:gen-class))
(defn -main
"echo server"
[port & args]
(let [ss (new ServerSocket (Integer/parseInt port))]
(loop []
(with-open [sock (.accept ss)
rdr (io/reader sock)]
(loop [line (.readLine rdr)]
(if line
(do (println line)
(recur (.readLine rdr))))))
(recur))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment