V
V
Vladimir Krauz2016-08-07 16:50:13
JavaScript
Vladimir Krauz, 2016-08-07 16:50:13

NodeJS How to listen unix socket?

Good afternoon.

Task:
Listen to unix sockets in nodejs using nodejs "net" library. It is desirable to paint in detail, because I have no idea how to work with them at all.
Some kind of socket file is being created there, I don’t know how and what.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zakhar Orlov, 2016-08-07
@MelancholicTheDie

const net = require('net')

// создаем сервер
const server = net.createServer(socket => {
  console.log('connected') // клиент присоединился
  socket.end('hello') // отвечаем и закрываем соединение
})

server.listen('/var/run/mysocket') // слушаем сокет

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question