Node.js - sharing partitions between processes

I read that you can split sockets between processes. Is this also possible in Node.js?

I saw an api cluster in Node.js, but that is not what I am looking for. I want to be able to accept a connection in one process, maybe send and read a bit, and after a while transfer this socket to another completely independent Node.js. process.

I could already do this with piping, but I do not want to do this, since it is not as fast as reading / writing directly to the socket itself.

Any ideas?

Update I found the following entry in the Node.js documentation:

new net.Socket([options]) # Construct a new socket object. options is an object with the following defaults: { fd: null type: null allowHalfOpen: false } fd allows you to specify the existing file descriptor of socket. type specified underlying protocol. It can be 'tcp4', 'tcp6', or 'unix'. About allowHalfOpen, refer to createServer() and 'end' event. 

I think it would be possible to set the “fd” property in the filedescriptor of the socket, and then open the socket with this. But ... How can I get the filedescriptor of the socket and pass it to the process that it needs?

Thanks for any help!

+6
source share
2 answers

This is not possible at the moment, but I added it as a function request to the node problems page.

Update Meanwhile, I wrote a module for this. You can find it here: https://github.com/VanCoding/node-ancillary

+1
source

You probably want to take a look at hook.io

hook.io is a distributed EventEmitter built on node.js. In addition to providing a minimal event structure, hook.io also provides a rich network of library listings for managing all kinds of input and output.

0
source

Source: https://habr.com/ru/post/903686/


All Articles