bash - Node.js Unix socket not echoing -


i trying create file can cat or echo strings , receive strings output. if understand correctly can unix socket.

i've tried write server can't seem recognize input:

'use strict';  var net = require('net'),     fs = require('fs'),     socketaddress = '/tmp/test-socket',     server;  server = net.createserver(function (client) {     var whole = '';     client.on('data', function (data) {         whole += data;     });     client.on('end', function () {         client.write(whole);     }); });  fs.unlink(socketaddress, function (error) {     if (error && error.code !== 'enoent') {         throw error;     }     server.listen(socketaddress, function () {         console.log('socket listening @ ' + socketaddress);     }); }); 

i try echo 'hello world!' | /tmp/test-socket , bash: /tmp/test-socket: no such device or address. ls -l /tmp yields:

srwxr-xr-x 1 jackson jackson 0 jun 1 01:10 test-socket

please advise on how can socket echo strings write it.

test-socket not program. pipe operator (|) tries execute next argument (in case test-socket) program or script , pass output stdin.

since sockets (named pipes) files, need use > or >> operator:

echo 'hello world!' > /tmp/test-socke 

this of course assumes node code working.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -