doc: improve rinfo object documentation

Provide details for fields of rinfo object of UDP message event.

PR-URL: https://github.com/nodejs/node/pull/10050
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Matt Crummey 2016-12-01 17:59:47 +00:00 committed by Rich Trott
parent a9b59ff8fb
commit 109bfd21d8

View File

@ -70,20 +70,14 @@ datagram messages. This occurs as soon as UDP sockets are created.
added: v0.1.99 added: v0.1.99
--> -->
The `'message'` event is emitted when a new datagram is available on a socket.
The event handler function is passed two arguments: `msg` and `rinfo`.
* `msg` {Buffer} - The message * `msg` {Buffer} - The message
* `rinfo` {Object} - Remote address information * `rinfo` {Object} - Remote address information
* `address` {String} The sender address
The `'message'` event is emitted when a new datagram is available on a socket. * `family` {String} The address family (`'IPv4'` or `'IPv6'`)
The event handler function is passed two arguments: `msg` and `rinfo`. The * `port` {Number} The sender port
`msg` argument is a [`Buffer`][] and `rinfo` is an object with the sender's * `size` {Number} The message size
address information provided by the `address`, `family` and `port` properties:
```js
socket.on('message', (msg, rinfo) => {
console.log('Received %d bytes from %s:%d\n',
msg.length, rinfo.address, rinfo.port);
});
```
### socket.addMembership(multicastAddress[, multicastInterface]) ### socket.addMembership(multicastAddress[, multicastInterface])
<!-- YAML <!-- YAML