Skip to content

Instantly share code, notes, and snippets.

@mrvisser
Last active August 29, 2015 13:55
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 mrvisser/8768446 to your computer and use it in GitHub Desktop.
Save mrvisser/8768446 to your computer and use it in GitHub Desktop.
var net = require('net');
var util = require('util');
var server = net.createServer(function(c) {
c.on('data', function(data) {
console.log('received data: %s', data.toString());
});
});
server.listen(8124, function() {
var client = net.connect({'port': 8124}, function() {
var b = new Buffer('hello ');
for (var i = 0; i < 121000; i ++) {
client.write(b);
if (i % 10000 === 0) {
console.log(client.bufferSize);
}
}
// Modify the buffer in place. Anything that gets held onto by _stream_writeable.js due to
// back-pressure will be handed to tcp_wrap (net.js) in a new tick and therefore this corruption
// will take effect
b[1] = 255;
client.end();
server.close();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment