2010-03-09 07:06:29 +08:00
|
|
|
require("../common");
|
2009-10-15 00:50:51 +08:00
|
|
|
|
2009-11-01 02:02:30 +08:00
|
|
|
tcp = require("tcp");
|
|
|
|
sys = require("sys");
|
|
|
|
var x = path.join(fixturesDir, "x.txt");
|
2009-10-15 00:50:51 +08:00
|
|
|
var expected = "xyz";
|
|
|
|
|
|
|
|
var server = tcp.createServer(function (socket) {
|
|
|
|
socket.addListener("receive", function (data) {
|
|
|
|
found = data;
|
|
|
|
client.close();
|
|
|
|
socket.close();
|
|
|
|
server.close();
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(expected, found);
|
2009-10-15 00:50:51 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
server.listen(PORT);
|
|
|
|
|
|
|
|
var client = tcp.createConnection(PORT);
|
|
|
|
client.addListener("connect", function () {
|
2010-02-17 15:06:26 +08:00
|
|
|
fs.open(x, 'r').addCallback(function (fd) {
|
|
|
|
fs.sendfile(client.fd, fd, 0, expected.length).addCallback(function (size) {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(expected.length, size);
|
2009-10-15 00:50:51 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|