Skip to content

Instantly share code, notes, and snippets.

@tomyan
Created July 20, 2013 14:21
Show Gist options
  • Select an option

  • Save tomyan/6045208 to your computer and use it in GitHub Desktop.

Select an option

Save tomyan/6045208 to your computer and use it in GitHub Desktop.
Demonstrates that data buffered on socket even when paused.
var server = require('net').createServer(function (socket) {
socket.pause();
function buffered () {
return (socket._readableState.buffer[0] || '').toString();
}
console.log(1, buffered());
setImmediate(function () {
console.log(2, buffered());
});
setTimeout(function () {
console.log(3, buffered());
}, 100);
});
server.listen(1337);
var client = require('net').connect(1337, function () {
client.end('some data');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment