Title: Proposal: child_process: Send socket but keep it open in parent · Issue #4271 · nodejs/node · GitHub
Open Graph Title: Proposal: child_process: Send socket but keep it open in parent · Issue #4271 · nodejs/node
X Title: Proposal: child_process: Send socket but keep it open in parent · Issue #4271 · nodejs/node
Description: The current behavior when sending a net.Socket object to a child process using child_process.ChildProcess.send() is to close the socket in the parent. This way, only the socket receiver can read and write to it. Problem: in some use-case...
Open Graph Description: The current behavior when sending a net.Socket object to a child process using child_process.ChildProcess.send() is to close the socket in the parent. This way, only the socket receiver can read an...
X Description: The current behavior when sending a net.Socket object to a child process using child_process.ChildProcess.send() is to close the socket in the parent. This way, only the socket receiver can read an...
Opengraph URL: https://github.com/nodejs/node/issues/4271
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: child_process: Send socket but keep it open in parent","articleBody":"The current behavior when sending a `net.Socket` object to a child process using `child_process.ChildProcess.send()` is to close the socket in the parent. This way, only the socket receiver can read and write to it.\n\nProblem: in some use-cases, a user may want to have BOTH parent and child to write to the TCP socket. For instance, I'm developing an app where a process writes data to the socket, whereas another one writes metadata. Sharing the socket in C, not in Node.js (currently).\n\nThe enhancement I propose is to add an optional `keepOpen` parameter to specify whether the parent should keep the socket open or not (it would default to `false` to keep existing behavior).\n\n``` js\nconst child = require('child_process').fork('child.js');\nconst server = require('net').createServer();\n\nserver.listen(1234).on('connection', function (socket) {\n child.send('socket', socket, { keepOpen: true });\n\n // Currently this crashes with: \"Error: This socket is closed.\"\n socket.write('-- hello from parent --');\n});\n```\n\nWhat I'm asking here is whether this is an acceptable enhancement or not. If it is, I'll start working on a clean pull request.\n","author":{"url":"https://github.com/adrienverge","@type":"Person","name":"adrienverge"},"datePublished":"2015-12-14T10:13:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4271/node/issues/4271"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c5a475e1-e805-08e3-b161-ffad1623b53b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BEE:11597D:A34C67:E3462E:6A4F46B5 |
| html-safe-nonce | 375ba4681e232cdd700f471ecdc87011de6160848bd697c5a2f6bfb63ed22d7a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkVFOjExNTk3RDpBMzRDNjc6RTM0NjJFOjZBNEY0NkI1IiwidmlzaXRvcl9pZCI6IjY0NTgwMjIyNDY2MzYwMTMyMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a41b54abbc920f4e6eb012cd7725bcb2c776dc961e828e75ee89475f84aa78f0 |
| hovercard-subject-tag | issue:122012293 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/4271/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f3825d4ab19679ffe381c59796ddf3786d857692432d024e411294bc3a72c5ff/nodejs/node/issues/4271 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f3825d4ab19679ffe381c59796ddf3786d857692432d024e411294bc3a72c5ff/nodejs/node/issues/4271 |
| og:image:alt | The current behavior when sending a net.Socket object to a child process using child_process.ChildProcess.send() is to close the socket in the parent. This way, only the socket receiver can read an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adrienverge |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width