0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/fixtures/net-fd-passing-receiver.js
Rich Trott 306936e98f test: change calls to deprecated util.print()
common.print() is just util.print() and as such prints a deprecation
warning. Per docs, update to console.log().

PR-URL: https://github.com/nodejs/node/pull/3083
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-09-28 13:21:15 -07:00

33 lines
760 B
JavaScript

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);