Created
December 27, 2019 21:25
-
-
Save r1b/c034c3b4ecbab620e0290d00980819f9 to your computer and use it in GitHub Desktop.
Extended example from node stream docs
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
const net = require('net'); | |
net.createServer((socket) => { | |
// We add an 'end' listener, but never consume the data. | |
socket.on('end', () => { | |
// It will never get here. | |
socket.end('The message was received but was not processed.\n'); | |
}); | |
}).listen(1337); | |
const client = net.connect({"host": "localhost", "port": 1337}); | |
client.on("connect", socket => { | |
// In fact, we DO enter the 'end' listener after this call! | |
socket.end(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment