GeezerVison is showing github.com — A way to pass a file descriptor to Node? · Issue #304 · nodejs/node-addon-api
A way to pass a file descriptor to Node? #304DescriptionAs compiling a NAPI module results in a library with a separate CRT, the state containing the FD table is different.
So if I have a situation where I have a HANDLE or an FD that I want to pass to Node - I find it problematic right now.
There's no API to accept a Windows' HANDLE, and no api to duplicate an FD into Node's namespace.
Anyone knows of a way to do that?
Thank you! Activitydanielgindi commented on Jul 17, 2018 Basically what I'm looking for is the inverse of uv_get_osfhandle bzoz commented on Jul 18, 2018 bzoz commented on Jul 18, 2018 i.e. are you looking for uv_open_osfhandle to get implemented? danielgindi commented on Jul 18, 2018 Exactly! uv_open_osfhandle... danielgindi commented on Jul 18, 2018 The thing is that the whole issue is about passing an fd across modules, which is not possible in most cases due to separate CRTs (even if you recompile node.exe with msvcrt.dll, you must compile against the same version...)
But if have a fd you can extract its HANDLE and pass it on to an exported uv_open_osfhandle function which will re-wrap it in its own CRT state.
So right now it's possible to get an FD from node and use it in a native addon, but not vice versa. bzoz commented on Oct 11, 2018 danielgindi commented on Oct 11, 2018 Yeah I already am enjoying this :-)
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|