FAQ
Hello,

I'm developing a C++ addon and I'm trying to access the object wrap of a
unix stream net.Socket. Basically what I'm doing is:

1) in C++ land

/* The first argument of the function is the socket */
Local<Object> obj = args[0]->ToObject();
if (obj->InternalFieldCount() > 0) {
PipeWrap* wrap =
static_cast<PipeWrap*>(obj->GetPointerFromInternalField(0));
}

2) in JS

var socket = new Socket(fd); // fd is a file descriptor of an already
created unix socket
my_function(socket); // call my_function implemented in the C++ addon

The problem I'm having is that the object internalFieldCount is 0. Any
ideas of what I'm doing wrong?

Thanks in advance.

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

  • Oleg Efimov (Sannis) at Jul 27, 2012 at 12:29 pm
    The real socket handle is stored in `socket._handle`, not in `socket`.

    пятница, 27 июля 2012 г., 16:04:44 UTC+4 пользователь sgimeno написал:
    Hello,

    I'm developing a C++ addon and I'm trying to access the object wrap of a
    unix stream net.Socket. Basically what I'm doing is:

    1) in C++ land

    /* The first argument of the function is the socket */
    Local<Object> obj = args[0]->ToObject();
    if (obj->InternalFieldCount() > 0) {
    PipeWrap* wrap =
    static_cast<PipeWrap*>(obj->GetPointerFromInternalField(0));
    }

    2) in JS

    var socket = new Socket(fd); // fd is a file descriptor of an already
    created unix socket
    my_function(socket); // call my_function implemented in the C++ addon

    The problem I'm having is that the object internalFieldCount is 0. Any
    ideas of what I'm doing wrong?

    Thanks in advance.

    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
  • Santiago Gimeno at Jul 27, 2012 at 12:46 pm
    It works now. Thanks!!

    2012/7/27 Oleg Efimov (Sannis) <efimovov@gmail.com>
    The real socket handle is stored in `socket._handle`, not in `socket`.

    пятница, 27 июля 2012 г., 16:04:44 UTC+4 пользователь sgimeno написал:
    Hello,

    I'm developing a C++ addon and I'm trying to access the object wrap of a
    unix stream net.Socket. Basically what I'm doing is:

    1) in C++ land

    /* The first argument of the function is the socket */
    Local<Object> obj = args[0]->ToObject();
    if (obj->InternalFieldCount() > 0) {
    PipeWrap* wrap = static_cast<PipeWrap*>(obj->**
    GetPointerFromInternalField(0)**);
    }

    2) in JS

    var socket = new Socket(fd); // fd is a file descriptor of an already
    created unix socket
    my_function(socket); // call my_function implemented in the C++ addon

    The problem I'm having is that the object internalFieldCount is 0. Any
    ideas of what I'm doing wrong?

    Thanks in advance.

    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
    --
    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 27, '12 at 12:05p
activeJul 27, '12 at 12:46p
posts3
users2
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase