summaryrefslogtreecommitdiff
path: root/doc/api/cluster.markdown
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2012-04-28 14:24:17 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2012-04-28 16:42:55 +0200
commitab072ee41693ee95667a06bce86588242c5b5869 (patch)
treefb7855241369da0974ccbcca3a7a0d6dc59d8392 /doc/api/cluster.markdown
parent12a90e98bfc347d78e622f0839898c065ed31dc1 (diff)
downloadnode-new-ab072ee41693ee95667a06bce86588242c5b5869.tar.gz
doc: document the address object in the cluster listening event
Diffstat (limited to 'doc/api/cluster.markdown')
-rw-r--r--doc/api/cluster.markdown13
1 files changed, 10 insertions, 3 deletions
diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown
index dc41a9c440..b4e6a3b25e 100644
--- a/doc/api/cluster.markdown
+++ b/doc/api/cluster.markdown
@@ -109,13 +109,19 @@ being executed.
## Event: 'listening'
* `worker` {Worker object}
+* `address` {Object}
When calling `listen()` from a worker, a 'listening' event is automatically assigned
to the server instance. When the server is listening a message is send to the master
where the 'listening' event is emitted.
- cluster.on('listening', function (worker) {
- console.log("We are now connected");
+The event handler is executed with two arguments, the `worker` contains the worker
+object and the `address` object contains the following connection properties:
+`address`, `port` and `addressType`. This is very useful if the worker is listening
+on more than one address.
+
+ cluster.on('listening', function (worker, address) {
+ console.log("A worker is now connected to " + address.address + ":" + address.port);
});
## Event: 'disconnect'
@@ -408,11 +414,12 @@ on the specified worker.
### Event: 'listening'
* `worker` {Worker object}
+* `address` {Object}
Same as the `cluster.on('listening')` event, but emits only when the state change
on the specified worker.
- cluster.fork().on('listening', function (worker) {
+ cluster.fork().on('listening', function (worker, address) {
// Worker is listening
};