0

I would like to have NodeJS API to be able to communicate with program (not wirtten by myself) which listens on localhost Unix socket 5050. I can 'echo' from shell to Unix socket 5050 where this program listens

$echo '{"output": "connecting"}' > /dev/tcp/localhost/5050

Now, for external programs to write to this localhost socket I need API, don't know how to do it:

app.post('/output', function (req, res) {    
    //echo '{"output": "connecting"}' > /dev/tcp/localhost/5050

});

1 Answer 1

1

You can connect to the unix socket via the same net.connect(). From there it's just a matter of writing to the socket (socket.write()) once the callback is called.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.