0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00
nodejs/test/mjsunit/test-fs-sendfile.js
Ryan Dahl 7a2e784ad7 Module refactor - almost CommonJS compatible now
API change summary:

  * require("/sys.js") becomes require("sys")

  * require("circle.js") becomes require("./circle")

  * process.path.join() becomes require("path").join()
2009-10-31 19:10:30 +01:00

28 lines
701 B
JavaScript

process.mixin(require("./common"));
tcp = require("tcp");
sys = require("sys");
PORT = 23123;
var x = 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,process.O_RDONLY, 0666).addCallback(function (fd) {
posix.sendfile(client.fd, fd, 0, expected.length).addCallback(function (size) {
assertEquals(expected.length, size);
});
});
});