Last active
August 29, 2015 13:55
-
-
Save mrvisser/8768446 to your computer and use it in GitHub Desktop.
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
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