FAQ
Hi guys, I need your help

As how node cluster module works, the workers works like normal Socket
Server, also it can listen to a public port, and handle the data client
pass it.

I have couple question about cluster.

1. listening
The master process listen at the public port, but what those workers with
the code `listen(port)` does? did the worker listen at somewhere, or it
just a fake listen?

2. receive data

If I am not misunderstanding, the data from client is send to the master
process, and the master process send an internalMessage like
worker.send(data), if so, the worker should handle data at
process.on('message',..) but not socket.on('data', ...), so we have to
change our workers code not like what cluster module did.

I notice there is a method called cluster._getServer, which would give the
worker a `handle` object which set to `socket._handle`.

3. send data back to client

When send to client, the worker process should send data to master process,
we need call `process.send` to the master process, and the master send data
back to client.

I know few thing about multi-process binding on a same port.

--
Best regards,

桂林 (Gui Lin)

guileen@twitter <https://twitter.com/#!/guileen>
桂糊涂@weibo <http://weibo.com/guileen>
guileen@github <https://github.com/guileen>

--
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

  • Ribao wei at Aug 30, 2012 at 3:40 pm
    Hi 桂林:

    Nice to see a Chinese in the maillist.

    From what I read, children processes do I/O directly, not through the
    master.

    Ribao Wei
    On Thu, Aug 30, 2012 at 9:58 AM, jason.桂林 wrote:

    Hi guys, I need your help

    As how node cluster module works, the workers works like normal Socket
    Server, also it can listen to a public port, and handle the data client
    pass it.

    I have couple question about cluster.

    1. listening
    The master process listen at the public port, but what those workers with
    the code `listen(port)` does? did the worker listen at somewhere, or it
    just a fake listen?

    2. receive data

    If I am not misunderstanding, the data from client is send to the master
    process, and the master process send an internalMessage like
    worker.send(data), if so, the worker should handle data at
    process.on('message',..) but not socket.on('data', ...), so we have to
    change our workers code not like what cluster module did.

    I notice there is a method called cluster._getServer, which would give the
    worker a `handle` object which set to `socket._handle`.

    3. send data back to client

    When send to client, the worker process should send data to master
    process, we need call `process.send` to the master process, and the master
    send data back to client.

    I know few thing about multi-process binding on a same port.

    --
    Best regards,

    桂林 (Gui Lin)

    guileen@twitter <https://twitter.com/#!/guileen>
    桂糊涂@weibo <http://weibo.com/guileen>
    guileen@github <https://github.com/guileen>

    --
    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
  • Jason.桂林 at Aug 30, 2012 at 10:48 pm
    nice to meet you too.

    all workers listen to the same address, why no problem like "address
    already bind".

    why i care about how it works because the i need dispatch connection to
    workers manually, and the connections need communication, you know like a
    chat server, A send message to B but they are not on the same process.
    在 2012-8-30 晚上11:34,"ribao wei" <ribao.w@gmail.com>写道:
    Hi 桂林:

    Nice to see a Chinese in the maillist.

    From what I read, children processes do I/O directly, not through the
    master.

    Ribao Wei
    On Thu, Aug 30, 2012 at 9:58 AM, jason.桂林 wrote:

    Hi guys, I need your help

    As how node cluster module works, the workers works like normal Socket
    Server, also it can listen to a public port, and handle the data client
    pass it.

    I have couple question about cluster.

    1. listening
    The master process listen at the public port, but what those workers with
    the code `listen(port)` does? did the worker listen at somewhere, or it
    just a fake listen?

    2. receive data

    If I am not misunderstanding, the data from client is send to the master
    process, and the master process send an internalMessage like
    worker.send(data), if so, the worker should handle data at
    process.on('message',..) but not socket.on('data', ...), so we have to
    change our workers code not like what cluster module did.

    I notice there is a method called cluster._getServer, which would give
    the worker a `handle` object which set to `socket._handle`.

    3. send data back to client

    When send to client, the worker process should send data to master
    process, we need call `process.send` to the master process, and the master
    send data back to client.

    I know few thing about multi-process binding on a same port.

    --
    Best regards,

    桂林 (Gui Lin)

    guileen@twitter <https://twitter.com/#!/guileen>
    桂糊涂@weibo <http://weibo.com/guileen>
    guileen@github <https://github.com/guileen>

    --
    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
    --
    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
  • Jg at Aug 31, 2012 at 10:46 am
    Perhaps the discussion found https://github.com/joyent/node/issues/3324
    might help you understand the way it works better. As to why the system
    doesn't error on children processes listening to the same port, I don't
    know.

    --
    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
postedAug 30, '12 at 1:58p
activeAug 31, '12 at 10:46a
posts4
users3
websitenodejs.org
irc#node.js

3 users in discussion

Jason.桂林: 2 posts Jg: 1 post Ribao wei: 1 post

People

Translate

site design / logo © 2022 Grokbase