Skip to content

Instantly share code, notes, and snippets.

@fijimunkii
Last active March 15, 2019 21:33
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 fijimunkii/e8b4769192f88f27bc034746de4e6b1f to your computer and use it in GitHub Desktop.
Save fijimunkii/e8b4769192f88f27bc034746de4e6b1f to your computer and use it in GitHub Desktop.
node http net socket middleman
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