node.js - Express.js - How to pass socket to child_process -


according

https://nodejs.org/api/child_process.html#child_process_example_sending_a_socket_object

you can pass socket connection child process can handle socket transactions independently. how achieve same thing req.socket object provided in express client making socket request io.socket.js? cannot do:

child.send("socket",req.socket") 

because req.socket not instance of net.socket fails following checks

if (handle instanceof net.socket) {   message.type = 'net.socket'; } else if (handle instanceof net.server) {   message.type = 'net.server'; } else if (handle instanceof process.binding('tcp_wrap').tcp ||        handle instanceof process.binding('pipe_wrap').pipe) {   message.type = 'net.native'; } else if (handle instanceof dgram.socket) {   message.type = 'dgram.socket'; } else if (handle instanceof process.binding('udp_wrap').udp) {   message.type = 'dgram.native'; } else {   throw new typeerror("this handle type can't sent"); } 

req.socket appears instance of net.socket when request normal http request (as opposed having been initiated on client io.socket.js).


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -