Skip to content

Official socket transfer support #8974

Description

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.

Activity

  1. Fishrock123 commented on Oct 7, 2016

    @Fishrock123
    Contributor

    Once you call .listen() you can access the net.Socket._handle property, which in turn has a fd property.

    _handle and _handle.fd are 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.

  2. added
    netIssues and PRs related to the net subsystem.
    on Oct 7, 2016
  3. added
    feature requestIssues requesting new Node.js features.
    and removed
    questionIssues asking questions about Node.js.
    on Oct 7, 2016
  4. Trott commented on Jul 12, 2017

    @Trott
    Member

    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?

  5. mcollina commented on Jul 12, 2017

    @mcollina
    SponsorMember

    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.

  6. bnoordhuis commented on Jul 12, 2017

    @bnoordhuis
    Member

    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.

  7. mcollina commented on Jul 12, 2017

    @mcollina
    SponsorMember

    @bnoordhuis thanks!

  8. bnoordhuis commented on Oct 5, 2017

    @bnoordhuis
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.netIssues and PRs related to the net subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions