joyent/node — pull request #4527 by shigeki (2013-01-07 01:55:43+00:00)
Title: net: fix bufferSize include writableStream length

socket.bufferSize missed to include the length of internal buffers in writableStream.
Testing results are shown below.
````
var net = require('net');

var server = net.createServer(function(socket) {
socket.on('readable', function() {
socket.read();
});
socket.on('end', function() {
server.close();
});
});
server.listen(1234, function() {
var client = net.connect(1234);
client.on('finish', function() {
console.log('finish: socket.bufferSize=' + client.bufferSize);
});
for(var i = 1; i < 10; i++) {
client.write('a');
console.log(i + ': socket.bufferSize= ' + client.bufferSize);
}
client.end();
});
````
node-v0.9.5,
````
1: socket.bufferSize= 0
2: socket.bufferSize= 0
3: socket.bufferSize= 0
4: socket.bufferSize= 0
5: socket.bufferSize= 0
6: socket.bufferSize= 0
7: socket.bufferSize= 0
8: socket.bufferSize= 0
9: socket.bufferSize= 0
finish: socket.bufferSize=0
````
after this commit,
````
1: socket.bufferSize= 1
2: socket.bufferSize= 2
3: socket.bufferSize= 3
4: socket.bufferSize= 4
5: socket.bufferSize= 5
6: socket.bufferSize= 6
7: socket.bufferSize= 7
8: socket.bufferSize= 8
9: socket.bufferSize= 9
finish: socket.bufferSize=0
````