-
-
Save sundarj/483a167ff9c3b42839d547b075d28b7a to your computer and use it in GitHub Desktop.
Clojure->Chrome Inspector
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
| (ns inspect | |
| (:require [cheshire.core :refer [generate-string]] | |
| [clojure.java.io :as io]) | |
| (:import (java.net Socket) | |
| (def host "localhost") | |
| (def port 9000) | |
| (defn cinspect [data] | |
| (with-open [sock (Socket. host port) | |
| writer (io/writer sock)] | |
| (->> data | |
| generate-string | |
| (.append writer) | |
| (.flush)))) | |
| (cinspect {:message "Hello!"}) |
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
| var net = require('net') | |
| var port = 9000 | |
| var server = net.createServer(socket => { | |
| let msg = '' | |
| socket | |
| .on('data', data => msg += data.toString()) | |
| .on('close', () => { | |
| console.clear() | |
| console.log(JSON.parse(msg)) | |
| msg = '' | |
| }) | |
| }) | |
| server.listen(port, () => { | |
| console.info("Server started on port:", port) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment