FAQ
Hello,

In the documentation of the Socket constructor there are two options: fd
and type that I've been trying to use with no luck.
What I was trying to do was:

1 - Create a Unix stream socket by calling a JS function bound to a C++
function that creates the unix socket and returns the fd.
2 - Create a net.Socket associated to the socket created in 1. For that I
was doing:

var my_socket = new Socket({ fd: my_fd, type: 'unix' } );

3- Connect to a remote server with socket.connect

But this was not working at all as a new socket was created.

By looking at the code in net.js I could not see any place where fd and
type options are handled. Am I missing something?

Thanks in advance.

BR

Santi

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

  • Ben Noordhuis at Jul 17, 2012 at 12:45 pm

    On Tue, Jul 17, 2012 at 10:07 AM, Santiago Gimeno wrote:
    Hello,

    In the documentation of the Socket constructor there are two options: fd and
    type that I've been trying to use with no luck.
    What I was trying to do was:

    1 - Create a Unix stream socket by calling a JS function bound to a C++
    function that creates the unix socket and returns the fd.
    2 - Create a net.Socket associated to the socket created in 1. For that I
    was doing:

    var my_socket = new Socket({ fd: my_fd, type: 'unix' } );

    3- Connect to a remote server with socket.connect

    But this was not working at all as a new socket was created.

    By looking at the code in net.js I could not see any place where fd and type
    options are handled. Am I missing something?
    I'm afraid the implementation and the documentation don't quite match
    up. I'll fix it one way or the other (either update the code or the
    docs.)

    `type` is a no-op now. `fd` works with some restrictions: use `new
    Socket(fd)` instead - if fd is a socket, it must be of type
    SOCK_STREAM.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Santiago Gimeno at Jul 17, 2012 at 4:05 pm
    Hi,

    2012/7/17 Ben Noordhuis <info@bnoordhuis.nl>
    `type` is a no-op now. `fd` works with some restrictions: use `new
    Socket(fd)` instead - if fd is a socket, it must be of type
    SOCK_STREAM.
    I've tried this with no luck. I still see that a new socket is created.

    The code I'm using is here: https://gist.github.com/3129376, and the
    missing C++ binding are copied from the ones in node-unix-dgram module.

    Running it with strace confirms the creation of the new socket:

    socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) =
    7

    bind(7, {sa_family=AF_FILE, path="/tmp/sock_terminal_node"}, 110) =


    socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) =
    8

    connect(8, {sa_family=AF_FILE, path="/tmp/echo_socket"}, 110) =


    getsockopt(8, SOL_SOCKET, SO_ERROR, [0], [4]) = 0

    Any ideas?

    Thanks,

    Santi

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedJul 17, '12 at 11:41a
activeJul 17, '12 at 4:05p
posts3
users2
websitenodejs.org
irc#node.js

2 users in discussion

Santiago Gimeno: 2 posts Ben Noordhuis: 1 post

People

Translate

site design / logo © 2022 Grokbase