Skip to content

Commit

Permalink
doc: improve rinfo object documentation
Browse files Browse the repository at this point in the history
Provide details for fields of rinfo object of UDP message event.

PR-URL: #10050
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Matt Crummey authored and evanlucas committed Jan 4, 2017
1 parent 5164b56 commit e86bf27
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions doc/api/dgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,14 @@ datagram messages. This occurs as soon as UDP sockets are created.
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
* `rinfo` {Object} - Remote address information

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`. The
`msg` argument is a [`Buffer`][] and `rinfo` is an object with the sender's
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);
});
```
* `address` {String} The sender address
* `family` {String} The address family (`'IPv4'` or `'IPv6'`)
* `port` {Number} The sender port
* `size` {Number} The message size

### socket.addMembership(multicastAddress[, multicastInterface])
<!-- YAML
Expand Down

0 comments on commit e86bf27

Please sign in to comment.