Created
September 3, 2017 15:24
-
-
Save rcanepa/31c6f477ba45f0f3e397842f335fa229 to your computer and use it in GitHub Desktop.
Sockets in Clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def IPaddress "XX.XX.XX.XX") | |
(def port 1234) | |
(def socket (Socket. IPaddress port)) | |
(println "Connected:" (.isConnected socket)) | |
(def in (DataInputStream. (BufferedInputStream. (.getInputStream socket)))) | |
(def out (DataOutputStream. (BufferedOutputStream. (.getOutputStream socket)))) | |
(def command "Some string") | |
(println "Input:" command) | |
(.writeUTF out command) | |
(.flush out) | |
(def response (.readUTF in)) | |
(println "Output: " response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment