mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3d8b14e6f7
use require("/posix.js") to access them.
28 lines
709 B
JavaScript
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);
|
|
});
|
|
});
|
|
});
|