Repository navigation
Official socket transfer support #8974
Description
Activity
- addedquestionIssues asking questions about Node.js.Issues asking questions about Node.js.
on Oct 7, 2016 Once you call
.listen()you can access thenet.Socket._handleproperty, which in turn has afdproperty._handleand_handle.fdare unlikely to be removed, and definitely will not disappear without significant fanfare with prior deprecation and semver-major (still, very unlikely). You should be good to use it, even if it is undocumented.- addednetIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
on Oct 7, 2016 - addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.and removedquestionIssues asking questions about Node.js.Issues asking questions about Node.js.
on Oct 7, 2016 This can be used to transfer a connection from JS land into an addon,
@bnoordhuis @indutny @nodejs/streams @nodejs/n-api Thoughts on how to do it now, how a new feature might do it, whether it is something that should be done at all, whether or not this issue should remain open?
I think the best way to do this is via uv_link_t, if that would ever be supported here. This is an issue also on core itsef, as I would love to not pass through JS to read data from TLS.
https://github.com/indutny/uv_link_t
I do not think that manipulating directly the fd and pointers is the way to go. Linking to the OpenSSL version that node use is impossible (I could not do it, maybe someone else can), so allowing this is not a good idea.
whether it is something that should be done at all
It's a pretty niche thing. Not saying no but there would probably only be a few users at best, making it not worthwhile to sink a lot of time into.
There's also the question of if you want to manage sockets yourself, why not create them yourself?
Linking to the OpenSSL version that node use is impossible
This has improved in the last year, see #6274.
@bnoordhuis thanks!
It's been a year since this issue was filed and there doesn't seem to be a whole lot of interest, never mind the practical considerations.
#7627 was closed as well so I'll close this out too. Please reopen if you think this needs to be revisited.
I'm interested in an official way of transferring a socket from Node.js (net.Socket / tls.TLSSocket) representation to the native representation (file descriptor / SOCKET descriptor + SSL pointer).
This can be used to transfer a connection from JS land into an addon, and have the addon manage the connection way more efficient.