Last active
March 15, 2019 21:33
-
-
Save fijimunkii/e8b4769192f88f27bc034746de4e6b1f to your computer and use it in GitHub Desktop.
node http net socket middleman
This file contains 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
const app = require('http').createServer((req, res) => { res.end((new Date()).toISOString()); }) | |
const listener = require('net').createServer(connection => { | |
connection.once('data', buffer => { | |
connection.pause(); | |
console.log(buffer.toString('utf8')); | |
app.emit('connection', connection); | |
connection.emit('data', buffer); | |
connection.resume(); | |
}); | |
}); | |
listener.listen(4000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment