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.
45 lines
1.0 KiB
45 lines
1.0 KiB
14 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var net = require('net');
|
||
|
var fs = require('fs');
|
||
|
var util = require('util');
|
||
|
var path = require('path');
|
||
14 years ago
|
var fn = path.join(common.fixturesDir, 'elipses.txt');
|
||
15 years ago
|
|
||
14 years ago
|
var expected = fs.readFileSync(fn, 'utf8');
|
||
15 years ago
|
|
||
14 years ago
|
var server = net.createServer(function(stream) {
|
||
15 years ago
|
common.error('pump!');
|
||
14 years ago
|
util.pump(fs.createReadStream(fn), stream, function() {
|
||
15 years ago
|
common.error('server stream close');
|
||
|
common.error('server close');
|
||
15 years ago
|
server.close();
|
||
|
});
|
||
|
});
|
||
|
|
||
14 years ago
|
server.listen(common.PORT, function() {
|
||
14 years ago
|
var conn = net.createConnection(common.PORT);
|
||
15 years ago
|
conn.setEncoding('utf8');
|
||
13 years ago
|
conn.on('data', function(chunk) {
|
||
15 years ago
|
common.error('recv data! nchars = ' + chunk.length);
|
||
15 years ago
|
buffer += chunk;
|
||
|
});
|
||
|
|
||
13 years ago
|
conn.on('end', function() {
|
||
15 years ago
|
conn.end();
|
||
|
});
|
||
13 years ago
|
conn.on('close', function() {
|
||
15 years ago
|
common.error('client connection close');
|
||
15 years ago
|
});
|
||
|
});
|
||
|
|
||
|
var buffer = '';
|
||
14 years ago
|
var count = 0;
|
||
15 years ago
|
|
||
13 years ago
|
server.on('listening', function() {
|
||
15 years ago
|
});
|
||
|
|
||
13 years ago
|
process.on('exit', function() {
|
||
15 years ago
|
assert.equal(expected, buffer);
|
||
|
});
|