node/test/disabled/test-fs-sendfile.js

29 lines
735 B
JavaScript
Raw Normal View History

2010-12-05 07:20:34 +08:00
var common = require('../common');
var assert = require('assert');
2009-10-15 00:50:51 +08:00
var net = require('net');
var util = require('util');
var x = path.join(common.fixturesDir, 'x.txt');
var expected = 'xyz';
2009-10-15 00:50:51 +08:00
var server = net.createServer(function(socket) {
socket.addListener('receive', function(data) {
2009-10-15 00:50:51 +08:00
found = data;
client.close();
socket.close();
server.close();
assert.equal(expected, found);
2009-10-15 00:50:51 +08:00
});
});
server.listen(common.PORT);
2009-10-15 00:50:51 +08:00
var client = net.createConnection(common.PORT);
client.addListener('connect', function() {
fs.open(x, 'r').addCallback(function(fd) {
fs.sendfile(client.fd, fd, 0, expected.length)
.addCallback(function(size) {
assert.equal(expected.length, size);
});
2009-10-15 00:50:51 +08:00
});
});