Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
a2ce384
deps: upgrade npm to 2.14.9
othiym23 Nov 6, 2015
542d05c
test: enhance fs-watch-recursive test
thefourtheye Aug 28, 2015
22208b0
build: fix configuring with prebuilt libraries
zyxar Sep 30, 2015
fa1ab49
docs: fs - change links to buffer encoding to Buffer class anchor
Oct 13, 2015
f50f19e
doc: stdout/stderr can block when directed to file
bnoordhuis Oct 3, 2015
12cdf6f
doc: add method links in events.markdown
a0viedo Nov 6, 2015
329e88e
repl: To exit, press ^C again or type .exit.
hemanth Nov 7, 2015
d1b5833
doc: add caveats of algs and key size in crypto
Jul 27, 2015
9b05905
src: Revert "nix stdin _readableState.reading"
silverwind Oct 26, 2015
a2efe4c
doc: add note about timeout delay > TIMEOUT_MAX
sitegui Oct 25, 2015
cf4b65c
doc:fix function param order in assert doc
birnam Oct 26, 2015
4733a60
zlib: pass kind to recursive calls to flush
Oct 26, 2015
47bb94a
zlib: only apply drain listener if given callback
CraigCav Oct 26, 2015
3aecbc8
test: add test-zlib-flush-drain
Nov 11, 2015
8a7dd73
doc: added what buf.copy returns
baslr Oct 28, 2015
907a13a
Add missing va_end before return
usta Oct 28, 2015
6db4392
doc: made code spans more visible in the API docs
phillipj Oct 28, 2015
d80fa2c
module: remove unnecessary JSON.stringify
zertosh Oct 29, 2015
11d2050
doc: Updated streams simplified constructor API
tomgco Oct 30, 2015
0e8eb66
test: fix path to module for repl test on Windows
mcornac Oct 30, 2015
347fb65
doc: fix crypto spkac function descriptions
jas- Oct 31, 2015
ff02b29
repl: don't crash if cannot open history file
evanlucas Nov 2, 2015
83494f8
doc: rename iojs-* groups to nodejs-*
srl295 Nov 2, 2015
eca5720
doc: fix wrong date and known issue in changelog.md
jasnell Nov 3, 2015
3dc52e9
test: fix test-net-persistent-keepalive for AIX
Nov 3, 2015
daa10a3
doc: typo fix in readme.md
SPGB Nov 3, 2015
7b4194a
test: fix test-module-loading-error for musl
hmalphettes Nov 10, 2015
fe3ae3c
doc: add LTS info to COLLABORATOR_GUIDE.md
Oct 19, 2015
488e74f
doc: update lts description in the collaborator guide
jasnell Nov 5, 2015
da189f7
test: Fix test-cluster-worker-exit.js for AIX
Nov 4, 2015
a558a57
util: use regexp instead of str.replace().join()
hellopao Nov 6, 2015
b140cb2
dns: prevent undefined values in results
Nov 6, 2015
4e5cae4
test: use really invalid hostname
thefourtheye Nov 8, 2015
f5c5e8b
cluster: send suicide message on disconnect
cjihrig Nov 9, 2015
5232512
doc: add thealphanerd to collaborators
Nov 9, 2015
4f7c638
doc: add saghul as a collaborator
saghul Nov 9, 2015
7b5e457
doc: add romankl to collaborators
r-52 Nov 9, 2015
3c415bb
doc: add note to util.isBuffer
evanlucas Nov 12, 2015
00b77d9
crypto: Improve error checking and reporting
stefanmb Nov 9, 2015
1bbc3b3
doc: add note on tls connection meta data methods
DaftMonk Nov 10, 2015
f43a033
doc: sort assert alphabetically
tflanagan Nov 4, 2015
af0bf1a
doc: sort buffer alphabetically
tflanagan Nov 4, 2015
5e79dc4
doc: sort child_process alphabetically
tflanagan Nov 4, 2015
28935a1
doc: sort cluster alphabetically
tflanagan Nov 4, 2015
435ffb7
doc: sort console alphabetically
tflanagan Nov 4, 2015
0e6121d
doc: sort dns alphabetically
tflanagan Nov 4, 2015
261e0f3
doc: sort crypto alphabetically
tflanagan Nov 4, 2015
c39eabb
doc: sort dgram alphabetically
tflanagan Nov 4, 2015
782cb7d
doc: sort errors alphabetically
tflanagan Nov 4, 2015
5b310f8
doc: sort events alphabetically
tflanagan Nov 4, 2015
6cd06c1
doc: sort fs alphabetically
tflanagan Nov 4, 2015
0906f9a
doc: sort globals alphabetically
tflanagan Nov 4, 2015
daa6244
doc: sort os alphabetically
tflanagan Nov 4, 2015
4d56960
doc: sort path alphabetically
tflanagan Nov 4, 2015
f37ff22
doc: sort punycode alphabetically
tflanagan Nov 4, 2015
ca41b55
doc: sort querystring alphabetically
tflanagan Nov 4, 2015
363692f
doc: sort vm alphabetically
tflanagan Nov 4, 2015
3c20687
doc: sort url alphabetically
tflanagan Nov 4, 2015
af876dd
doc: sort tty alphabetically
tflanagan Nov 4, 2015
3f3b9ed
doc: sort timers alphabetically
tflanagan Nov 4, 2015
34b8d28
doc: sort string_decoder alphabetically
tflanagan Nov 4, 2015
660062b
doc: sort repl alphabetically
tflanagan Nov 4, 2015
71722fe
doc: sort readline alphabetically
tflanagan Nov 4, 2015
dedfb11
doc: sort modules alphabetically
tflanagan Nov 4, 2015
3546eb4
doc: sort http alphabetically
tflanagan Nov 4, 2015
48fc765
doc: sort https alphabetically
tflanagan Nov 4, 2015
9878034
doc: sort util alphabetically
tflanagan Nov 5, 2015
37033dc
doc: sort zlib alphabetically
tflanagan Nov 5, 2015
6de8874
doc: sort process alphabetically
tflanagan Nov 5, 2015
e98e8af
doc: sort net alphabetically
tflanagan Nov 5, 2015
39fa9fa
doc: sort stream alphabetically
tflanagan Nov 5, 2015
90fdb4f
doc: sort tls alphabetically
tflanagan Nov 5, 2015
29f26b8
doc: add link to [customizing util.inspect colors].
jmm Nov 10, 2015
15fb029
doc: document release types in readme
rvagg Oct 22, 2015
eab0d56
doc: repl: add defineComand and displayPrompt
bengl Nov 11, 2015
6c23f67
test: fix flaky test test-http-pipeline-flood
Sep 14, 2015
93d1d3c
test: refactor test-http-pipeline-flood
Trott Nov 2, 2015
b2cc130
docs: improve discoverability of Code of Conduct
ashleygwilliams Nov 11, 2015
b22973a
doc: replace head of readme with updated text
rvagg Oct 22, 2015
6de77cd
doc: clarify duplicate header handling
bengl Nov 13, 2015
a36a5b6
doc: reword message.headers to indicate they are not read-only
tflanagan Nov 13, 2015
ffd3335
doc: address use of profanity in code of conduct
jasnell Nov 14, 2015
6b172d9
doc: consistent reference-style links
bengl Nov 14, 2015
c31d472
doc: sort repl alphabetically
tflanagan Nov 16, 2015
9e1edea
deps: backport 819b40a from V8 upstream
targos Nov 20, 2015
8f0291b
doc: update WORKING_GROUPS.md to include Intl
srl295 Oct 7, 2015
753c507
doc: Adding best practises for crypto.pbkdf2
tomgco Oct 9, 2015
c10c086
tls: remove util and calls to util.format
Oct 20, 2015
5207099
doc: clarify that fs streams expect blocking fd
XeCycle Nov 3, 2015
9a6c9fa
test: numeric flags to fs.open
XeCycle Nov 3, 2015
4c382e7
doc: numeric flags to fs.open
XeCycle Nov 3, 2015
236ad90
child_process: don't fork bomb ourselves from -e
bnoordhuis Oct 28, 2015
f28f69d
cluster: remove handles when disconnecting worker
bnoordhuis Nov 3, 2015
0eb0119
tls: Use SHA1 for sessionIdContext in FIPS mode
stefanmb Nov 9, 2015
2e9b886
crypto: DSA parameter validation in FIPS mode
stefanmb Nov 10, 2015
f30214f
test: add test for invalid DSA key size
stefanmb Nov 13, 2015
7c5fbf7
test: add hasFipsCrypto to test/common.js
stefanmb Nov 12, 2015
1f83eeb
test: increase crypto strength for FIPS standard
stefanmb Nov 10, 2015
3f9562b
test: stronger crypto in test fixtures
stefanmb Nov 10, 2015
4a26f74
test: skip/replace weak crypto tests in FIPS mode
stefanmb Nov 10, 2015
db0186e
buffer: let WriteFloatGeneric silently drop values
pmq20 Nov 16, 2015
914caf9
child_process: add safety checks on stdio access
cjihrig Nov 12, 2015
803a56d
querystring: Parse multiple separator characters
yosuke-furukawa Nov 12, 2015
60dda70
build: fix --with-intl=system-icu for x-compile
srl295 Nov 13, 2015
603a6f5
test: run pipeline flood test in parallel
Trott Nov 13, 2015
150f126
test: fix flaky SmartOS test
Trott Nov 15, 2015
9ea6bc1
test: skip test if FreeBSD jail will break it
Trott Nov 15, 2015
fb8df8d
test: module loading error fix solaris #3798
Nov 16, 2015
971762a
module: cache regular expressions
evanlucas Nov 17, 2015
cca216a
test: move test-specific function out of common
Trott Nov 17, 2015
b9d7378
test: fix flaky test-child-process-spawnsync-input
Trott Nov 17, 2015
dbc85a2
test: avoid test timeouts on rpi
stefanmb Nov 18, 2015
4bc71e0
doc: clarify module loading behavior
cjihrig Nov 19, 2015
8eb28c3
doc: add reference for buffer.inspect()
cjihrig Nov 19, 2015
5a27274
test: retry on smartos if ECONNREFUSED
Trott Nov 20, 2015
bd82fb0
doc: fix broken references
gromnitsky Nov 20, 2015
aa85d62
net: add local address/port for better errors
jscissr Nov 20, 2015
c5be3c6
doc: fix rare case of misaligned columns
silverwind Nov 21, 2015
e66794f
test: address flaky test-http-client-timeout-event
Trott Nov 22, 2015
b2f1014
test: remove flaky status for cluster test
Trott Nov 23, 2015
6ef3625
doc: replace sane with reasonable
lewiscowper Nov 23, 2015
cc24f0e
test: fix test-domain-exit-dispose-again
Nov 23, 2015
38ba152
test: skip test if in FreeBSD jail
Trott Nov 24, 2015
b48d5ec
doc: message.header duplication correction
bengl Nov 24, 2015
bebde48
doc: fix typo in README
Trott Nov 24, 2015
abbd87b
test: mark fork regression test flaky on windows
Trott Nov 25, 2015
44a2d8c
doc: fix color of linked code blocks
Nov 29, 2015
6950155
test: remove flaky designation from ls-no-sslv3
Trott Nov 1, 2015
05b64c1
test: mark cluster-net-send test flaky on windows
Trott Nov 24, 2015
4ea1a69
test: mark test flaky on FreeBSD
Trott Nov 25, 2015
51ae8d1
deps: Updated node LICENSE file with new npm license
zkat Dec 2, 2015
da8d012
doc: clarify v4.2.3 notable items
rvagg Dec 4, 2015
1e1173f
configure: respect CC_host in host arch detection
joaocgreis Dec 2, 2015
3094464
configure: use __ARM_ARCH to determine arm version
joaocgreis Dec 2, 2015
3327415
doc: fix the exception description
yorkie Nov 4, 2015
4e46e04
test: add test for repl.defineCommand()
bengl Nov 19, 2015
beee055
doc: update WORKING_GROUPS.md - add missing groups
mhdawson Oct 20, 2015
f93d268
doc: add HTTP working group
jasnell Nov 19, 2015
355edf5
test: fix cluster-worker-isdead
santigimeno Nov 21, 2015
5f66d66
test: don't check the # of chunks in test-http-1.0
santigimeno Nov 21, 2015
7ffc017
buffer: fix writeInt{B,L}E for some neg values
pabigot Nov 23, 2015
541d0d2
test: fix cluster-disconnect-handles flakiness
santigimeno Nov 24, 2015
5c67408
build: update signtool description, add url
rvagg Nov 24, 2015
629d5d1
configure: `v8_use_snapshot` should be `true`
indutny Nov 22, 2015
957c1f2
stream_wrap: error if stream has StringDecoder
indutny Dec 5, 2015
43e3b69
test: refactor test-http-exit-delay
Trott Nov 28, 2015
dcfdbac
doc: reword https.Agent example text
Nov 30, 2015
72f43a2
doc: fix internal link to child.send()
lpinca Dec 1, 2015
8aafa2e
doc: standardize references to node.js in docs
scottsb Dec 3, 2015
0311836
meta: remove use of profanity in source
Dec 2, 2015
34e64e5
domains: fix handling of uncaught exceptions
Nov 3, 2015
51c9059
deps: upgrade to npm 2.14.12
zkat Dec 1, 2015
6fe5a18
2015-12-17, Version 4.2.4 "Argon" (LTS) Release
jasnell Dec 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: sort dgram alphabetically
Reorders, with no contextual changes, the dgram documentation
alphabetically.

PR-URL: #3662
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
tflanagan authored and jasnell committed Dec 17, 2015
commit c39eabbec4a46f6c49662be923cbed0b50740351
301 changes: 149 additions & 152 deletions doc/api/dgram.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,11 @@ You have to change it to this:
s.addMembership('224.0.0.114');
});


## dgram.createSocket(type[, callback])

* `type` String. Either 'udp4' or 'udp6'
* `callback` Function. Attached as a listener to `message` events.
Optional
* Returns: Socket object

Creates a datagram Socket of the specified types. Valid types are `udp4`
and `udp6`.

Takes an optional callback which is added as a listener for `message` events.

Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
bind to the "all interfaces" address on a random port (it does the right thing
for both `udp4` and `udp6` sockets). You can then retrieve the address and port
with `socket.address().address` and `socket.address().port`.

## dgram.createSocket(options[, callback])
* `options` Object
* `callback` Function. Attached as a listener to `message` events.
* Returns: Socket object

The `options` object should contain a `type` field of either `udp4` or `udp6`
and an optional boolean `reuseAddr` field.

When `reuseAddr` is `true` `socket.bind()` will reuse the address, even if
another process has already bound a socket on it. `reuseAddr` defaults to
`false`.

Takes an optional callback which is added as a listener for `message` events.

Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
bind to the "all interfaces" address on a random port (it does the right thing
for both `udp4` and `udp6` sockets). You can then retrieve the address and port
with `socket.address().address` and `socket.address().port`.

## Class: dgram.Socket

The dgram Socket class encapsulates the datagram functionality. It
should be created via `dgram.createSocket(...)`

### Event: 'message'

* `msg` Buffer object. The message
* `rinfo` Object. Remote address information

Emitted when a new datagram is available on a socket. `msg` is a `Buffer` and
`rinfo` is an object with the sender's address information:

socket.on('message', function(msg, rinfo) {
console.log('Received %d bytes from %s:%d\n',
msg.length, rinfo.address, rinfo.port);
});

### Event: 'listening'

Emitted when a socket starts listening for datagrams. This happens as soon as UDP sockets
are created.

### Event: 'close'

Emitted after a socket is closed with `close()`. No new `message` events will be emitted
Expand All @@ -91,72 +36,38 @@ on this socket.

Emitted when an error occurs.

### socket.send(buf, offset, length, port, address[, callback])

* `buf` Buffer object or string. Message to be sent
* `offset` Integer. Offset in the buffer where the message starts.
* `length` Integer. Number of bytes in the message.
* `port` Integer. Destination port.
* `address` String. Destination hostname or IP address.
* `callback` Function. Called when the message has been sent. Optional.

For UDP sockets, the destination port and address must be specified. A string
may be supplied for the `address` parameter, and it will be resolved with DNS.

If the address is omitted or is an empty string, `'0.0.0.0'` or `'::0'` is used
instead. Depending on the network configuration, those defaults may or may not
work; it's best to be explicit about the destination address.
### Event: 'listening'

If the socket has not been previously bound with a call to `bind`, it gets
assigned a random port number and is bound to the "all interfaces" address
(`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
Emitted when a socket starts listening for datagrams. This happens as soon as UDP sockets
are created.

An optional callback may be specified to detect DNS errors or for determining
when it's safe to reuse the `buf` object. Note that DNS lookups delay the time
to send for at least one tick. The only way to know for sure that the datagram
has been sent is by using a callback. If an error occurs and a callback is
given, the error will be the first argument to the callback. If a callback is
not given, the error is emitted as an `'error'` event on the `socket` object.
### Event: 'message'

With consideration for multi-byte characters, `offset` and `length` will
be calculated with respect to
[byte length](buffer.html#buffer_class_method_buffer_bytelength_string_encoding)
and not the character position.
* `msg` Buffer object. The message
* `rinfo` Object. Remote address information

Example of sending a UDP packet to a random port on `localhost`;
Emitted when a new datagram is available on a socket. `msg` is a `Buffer` and
`rinfo` is an object with the sender's address information:

var dgram = require('dgram');
var message = new Buffer("Some bytes");
var client = dgram.createSocket("udp4");
client.send(message, 0, message.length, 41234, "localhost", function(err) {
client.close();
socket.on('message', function(msg, rinfo) {
console.log('Received %d bytes from %s:%d\n',
msg.length, rinfo.address, rinfo.port);
});

**A Note about UDP datagram size**
### socket.addMembership(multicastAddress[, multicastInterface])

The maximum size of an `IPv4/v6` datagram depends on the `MTU` (_Maximum Transmission Unit_)
and on the `Payload Length` field size.
* `multicastAddress` String
* `multicastInterface` String, Optional

- The `Payload Length` field is `16 bits` wide, which means that a normal payload
cannot be larger than 64K octets including internet header and data
(65,507 bytes = 65,535 − 8 bytes UDP header − 20 bytes IP header);
this is generally true for loopback interfaces, but such long datagrams
are impractical for most hosts and networks.
Tells the kernel to join a multicast group with `IP_ADD_MEMBERSHIP` socket option.

- The `MTU` is the largest size a given link layer technology can support for datagrams.
For any link, `IPv4` mandates a minimum `MTU` of `68` octets, while the recommended `MTU`
for IPv4 is `576` (typically recommended as the `MTU` for dial-up type applications),
whether they arrive whole or in fragments.
If `multicastInterface` is not specified, the OS will try to add membership to all valid
interfaces.

For `IPv6`, the minimum `MTU` is `1280` octets, however, the mandatory minimum
fragment reassembly buffer size is `1500` octets.
The value of `68` octets is very small, since most current link layer technologies have
a minimum `MTU` of `1500` (like Ethernet).
### socket.address()

Note that it's impossible to know in advance the MTU of each link through which
a packet might travel, and that generally sending a datagram greater than
the (receiver) `MTU` won't work (the packet gets silently dropped, without
informing the source that the data did not reach its intended recipient).
Returns an object containing the address information for a socket. For UDP sockets,
this object will contain `address` , `family` and `port`.

### socket.bind([port][, address][, callback])

Expand Down Expand Up @@ -204,7 +115,6 @@ Example of a UDP server listening on port 41234:
server.bind(41234);
// server listening 0.0.0.0:41234


### socket.bind(options[, callback])

* `options` {Object} - Required. Supports the following properties:
Expand All @@ -230,16 +140,90 @@ shown below.
exclusive: true
});


### socket.close([callback])

Close the underlying socket and stop listening for data on it. If a callback is
provided, it is added as a listener for the ['close'](#dgram_event_close) event.

### socket.address()
### socket.dropMembership(multicastAddress[, multicastInterface])

Returns an object containing the address information for a socket. For UDP sockets,
this object will contain `address` , `family` and `port`.
* `multicastAddress` String
* `multicastInterface` String, Optional

Opposite of `addMembership` - tells the kernel to leave a multicast group with
`IP_DROP_MEMBERSHIP` socket option. This is automatically called by the kernel
when the socket is closed or process terminates, so most apps will never need to call
this.

If `multicastInterface` is not specified, the OS will try to drop membership to all valid
interfaces.

### socket.send(buf, offset, length, port, address[, callback])

* `buf` Buffer object or string. Message to be sent
* `offset` Integer. Offset in the buffer where the message starts.
* `length` Integer. Number of bytes in the message.
* `port` Integer. Destination port.
* `address` String. Destination hostname or IP address.
* `callback` Function. Called when the message has been sent. Optional.

For UDP sockets, the destination port and address must be specified. A string
may be supplied for the `address` parameter, and it will be resolved with DNS.

If the address is omitted or is an empty string, `'0.0.0.0'` or `'::0'` is used
instead. Depending on the network configuration, those defaults may or may not
work; it's best to be explicit about the destination address.

If the socket has not been previously bound with a call to `bind`, it gets
assigned a random port number and is bound to the "all interfaces" address
(`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)

An optional callback may be specified to detect DNS errors or for determining
when it's safe to reuse the `buf` object. Note that DNS lookups delay the time
to send for at least one tick. The only way to know for sure that the datagram
has been sent is by using a callback. If an error occurs and a callback is
given, the error will be the first argument to the callback. If a callback is
not given, the error is emitted as an `'error'` event on the `socket` object.

With consideration for multi-byte characters, `offset` and `length` will
be calculated with respect to
[byte length](buffer.html#buffer_class_method_buffer_bytelength_string_encoding)
and not the character position.

Example of sending a UDP packet to a random port on `localhost`;

var dgram = require('dgram');
var message = new Buffer("Some bytes");
var client = dgram.createSocket("udp4");
client.send(message, 0, message.length, 41234, "localhost", function(err) {
client.close();
});

**A Note about UDP datagram size**

The maximum size of an `IPv4/v6` datagram depends on the `MTU` (_Maximum Transmission Unit_)
and on the `Payload Length` field size.

- The `Payload Length` field is `16 bits` wide, which means that a normal payload
cannot be larger than 64K octets including internet header and data
(65,507 bytes = 65,535 − 8 bytes UDP header − 20 bytes IP header);
this is generally true for loopback interfaces, but such long datagrams
are impractical for most hosts and networks.

- The `MTU` is the largest size a given link layer technology can support for datagrams.
For any link, `IPv4` mandates a minimum `MTU` of `68` octets, while the recommended `MTU`
for IPv4 is `576` (typically recommended as the `MTU` for dial-up type applications),
whether they arrive whole or in fragments.

For `IPv6`, the minimum `MTU` is `1280` octets, however, the mandatory minimum
fragment reassembly buffer size is `1500` octets.
The value of `68` octets is very small, since most current link layer technologies have
a minimum `MTU` of `1500` (like Ethernet).

Note that it's impossible to know in advance the MTU of each link through which
a packet might travel, and that generally sending a datagram greater than
the (receiver) `MTU` won't work (the packet gets silently dropped, without
informing the source that the data did not reach its intended recipient).

### socket.setBroadcast(flag)

Expand All @@ -248,18 +232,12 @@ this object will contain `address` , `family` and `port`.
Sets or clears the `SO_BROADCAST` socket option. When this option is set, UDP packets
may be sent to a local interface's broadcast address.

### socket.setTTL(ttl)

* `ttl` Integer
### socket.setMulticastLoopback(flag)

Sets the `IP_TTL` socket option. TTL stands for "Time to Live," but in this context it
specifies the number of IP hops that a packet is allowed to go through. Each router or
gateway that forwards a packet decrements the TTL. If the TTL is decremented to 0 by a
router, it will not be forwarded. Changing TTL values is typically done for network
probes or when multicasting.
* `flag` Boolean

The argument to `setTTL()` is a number of hops between 1 and 255. The default on most
systems is 64.
Sets or clears the `IP_MULTICAST_LOOP` socket option. When this option is set, multicast
packets will also be received on the local interface.

### socket.setMulticastTTL(ttl)

Expand All @@ -273,35 +251,26 @@ decrements the TTL. If the TTL is decremented to 0 by a router, it will not be f
The argument to `setMulticastTTL()` is a number of hops between 0 and 255. The default on most
systems is 1.

### socket.setMulticastLoopback(flag)

* `flag` Boolean

Sets or clears the `IP_MULTICAST_LOOP` socket option. When this option is set, multicast
packets will also be received on the local interface.

### socket.addMembership(multicastAddress[, multicastInterface])

* `multicastAddress` String
* `multicastInterface` String, Optional
### socket.setTTL(ttl)

Tells the kernel to join a multicast group with `IP_ADD_MEMBERSHIP` socket option.
* `ttl` Integer

If `multicastInterface` is not specified, the OS will try to add membership to all valid
interfaces.
Sets the `IP_TTL` socket option. TTL stands for "Time to Live," but in this context it
specifies the number of IP hops that a packet is allowed to go through. Each router or
gateway that forwards a packet decrements the TTL. If the TTL is decremented to 0 by a
router, it will not be forwarded. Changing TTL values is typically done for network
probes or when multicasting.

### socket.dropMembership(multicastAddress[, multicastInterface])
The argument to `setTTL()` is a number of hops between 1 and 255. The default on most
systems is 64.

* `multicastAddress` String
* `multicastInterface` String, Optional
### socket.ref()

Opposite of `addMembership` - tells the kernel to leave a multicast group with
`IP_DROP_MEMBERSHIP` socket option. This is automatically called by the kernel
when the socket is closed or process terminates, so most apps will never need to call
this.
Opposite of `unref`, calling `ref` on a previously `unref`d socket will *not*
let the program exit if it's the only socket left (the default behavior). If
the socket is `ref`d calling `ref` again will have no effect.

If `multicastInterface` is not specified, the OS will try to drop membership to all valid
interfaces.
Returns `socket`.

### socket.unref()

Expand All @@ -311,10 +280,38 @@ active socket in the event system. If the socket is already `unref`d calling

Returns `socket`.

### socket.ref()
## dgram.createSocket(options[, callback])
* `options` Object
* `callback` Function. Attached as a listener to `message` events.
* Returns: Socket object

Opposite of `unref`, calling `ref` on a previously `unref`d socket will *not*
let the program exit if it's the only socket left (the default behavior). If
the socket is `ref`d calling `ref` again will have no effect.
The `options` object should contain a `type` field of either `udp4` or `udp6`
and an optional boolean `reuseAddr` field.

Returns `socket`.
When `reuseAddr` is `true` `socket.bind()` will reuse the address, even if
another process has already bound a socket on it. `reuseAddr` defaults to
`false`.

Takes an optional callback which is added as a listener for `message` events.

Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
bind to the "all interfaces" address on a random port (it does the right thing
for both `udp4` and `udp6` sockets). You can then retrieve the address and port
with `socket.address().address` and `socket.address().port`.

## dgram.createSocket(type[, callback])

* `type` String. Either 'udp4' or 'udp6'
* `callback` Function. Attached as a listener to `message` events.
Optional
* Returns: Socket object

Creates a datagram Socket of the specified types. Valid types are `udp4`
and `udp6`.

Takes an optional callback which is added as a listener for `message` events.

Call `socket.bind()` if you want to receive datagrams. `socket.bind()` will
bind to the "all interfaces" address on a random port (it does the right thing
for both `udp4` and `udp6` sockets). You can then retrieve the address and port
with `socket.address().address` and `socket.address().port`.