|
@ -17,20 +17,22 @@ var bufferSize = 5 * 1024 * 1024; |
|
|
*/ |
|
|
*/ |
|
|
var buffer = Buffer(bufferSize); |
|
|
var buffer = Buffer(bufferSize); |
|
|
for (var i = 0; i < buffer.length; i++) { |
|
|
for (var i = 0; i < buffer.length; i++) { |
|
|
buffer[i] = parseInt(Math.random()*10000) % 256; |
|
|
buffer[i] = 100; //parseInt(Math.random()*10000) % 256;
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var web = http.Server(function (req, res) { |
|
|
var web = http.Server(function (req, res) { |
|
|
web.close(); |
|
|
web.close(); |
|
|
|
|
|
|
|
|
|
|
|
console.log("web server connection fd=%d", req.connection.fd); |
|
|
|
|
|
|
|
|
console.log(req.headers); |
|
|
console.log(req.headers); |
|
|
|
|
|
|
|
|
var socket = net.Stream(); |
|
|
var socket = net.Stream(); |
|
|
socket.connect(tcpPort); |
|
|
socket.connect(tcpPort); |
|
|
|
|
|
|
|
|
socket.on('connect', function () { |
|
|
socket.on('connect', function () { |
|
|
console.log('socket connected'); |
|
|
console.log('http->tcp connected fd=%d', socket.fd); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
req.pipe(socket); |
|
|
req.pipe(socket); |
|
@ -54,7 +56,7 @@ web.listen(webPort, startClient); |
|
|
var tcp = net.Server(function (s) { |
|
|
var tcp = net.Server(function (s) { |
|
|
tcp.close(); |
|
|
tcp.close(); |
|
|
|
|
|
|
|
|
console.log("tcp server connection"); |
|
|
console.log("tcp server connection fd=%d", s.fd); |
|
|
|
|
|
|
|
|
var i = 0; |
|
|
var i = 0; |
|
|
|
|
|
|
|
@ -91,6 +93,12 @@ function startClient () { |
|
|
req.write(buffer); |
|
|
req.write(buffer); |
|
|
req.end(); |
|
|
req.end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("request fd=%d", req.connection.fd); |
|
|
|
|
|
|
|
|
|
|
|
// note the queue includes http headers.
|
|
|
|
|
|
assert.ok(req.connection.writeQueueSize() > buffer.length); |
|
|
|
|
|
|
|
|
req.on('response', function (res) { |
|
|
req.on('response', function (res) { |
|
|
console.log('Got response'); |
|
|
console.log('Got response'); |
|
|
res.setEncoding('utf8'); |
|
|
res.setEncoding('utf8'); |
|
|