0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/mjsunit/test-fs-sendfile.js
Ryan Dahl 3d8b14e6f7 node.fs.* moved into "/posix.js"
use require("/posix.js") to access them.
2009-10-28 22:45:46 +01:00

28 lines
709 B
JavaScript

node.mixin(require("common.js"));
tcp = require("/tcp.js");
sys = require("/sys.js");
PORT = 23123;
var x = node.path.join(fixturesDir, "x.txt");
var expected = "xyz";
var server = tcp.createServer(function (socket) {
socket.addListener("receive", function (data) {
found = data;
client.close();
socket.close();
server.close();
assertEquals(expected, found);
});
});
server.listen(PORT);
var client = tcp.createConnection(PORT);
client.addListener("connect", function () {
posix.open(x,node.O_RDONLY, 0666).addCallback(function (fd) {
posix.sendfile(client.fd, fd, 0, expected.length).addCallback(function (size) {
assertEquals(expected.length, size);
});
});
});