mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
735 B
28 lines
735 B
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
var net = require('net');
|
|
var util = require('util');
|
|
var x = path.join(common.fixturesDir, 'x.txt');
|
|
var expected = 'xyz';
|
|
|
|
var server = net.createServer(function(socket) {
|
|
socket.addListener('receive', function(data) {
|
|
found = data;
|
|
client.close();
|
|
socket.close();
|
|
server.close();
|
|
assert.equal(expected, found);
|
|
});
|
|
});
|
|
server.listen(common.PORT);
|
|
|
|
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);
|
|
});
|
|
});
|
|
});
|
|
|