blob: fb4faee1264464333f72911eefba6886f583a5c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
process.mixin(require('../common'));
net = require('net');
path = process.ARGV[2];
greeting = process.ARGV[3];
receiver = net.createServer(function(socket) {
socket.on('fd', function(fd) {
var peerInfo = process.getpeername(fd);
peerInfo.fd = fd;
var passedSocket = new net.Socket(peerInfo);
passedSocket.on('eof', function() {
passedSocket.close();
});
passedSocket.on('data', function(data) {
passedSocket.send(`[echo] ${data}`);
});
passedSocket.on('close', function() {
receiver.close();
});
passedSocket.send(`[greeting] ${greeting}`);
});
});
/* To signal the test runne we're up and listening */
receiver.on('listening', function() {
console.log('ready');
});
receiver.listen(path);
|