2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
2010-12-06 06:33:52 +08:00
|
|
|
var assert = require('assert');
|
2009-10-15 00:50:51 +08:00
|
|
|
|
2010-12-06 06:33:52 +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
|
|
|
|
2010-12-06 06:33:52 +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();
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(expected, found);
|
2009-10-15 00:50:51 +08:00
|
|
|
});
|
|
|
|
});
|
2010-07-16 02:47:25 +08:00
|
|
|
server.listen(common.PORT);
|
2009-10-15 00:50:51 +08:00
|
|
|
|
2010-12-06 06:33:52 +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
|
|
|
});
|
|
|
|
});
|