diff options
Diffstat (limited to 'doc/api/dgram.markdown')
-rw-r--r-- | doc/api/dgram.markdown | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/doc/api/dgram.markdown b/doc/api/dgram.markdown index 33541e4737..09bacaf098 100644 --- a/doc/api/dgram.markdown +++ b/doc/api/dgram.markdown @@ -22,13 +22,8 @@ You have to change it to this: ## dgram.createSocket(type[, callback]) -## dgram.createSocket(options[, callback]) * `type` String. Either 'udp4' or 'udp6' -* `options` Object. Should contain a `type` property and could contain - `reuseAddr` property. `false` by default. - When `reuseAddr` is `true` - `socket.bind()` will reuse address, even if the - other process has already bound a socket on it. * `callback` Function. Attached as a listener to `message` events. Optional * Returns: Socket object @@ -38,9 +33,28 @@ 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 +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 @@ -142,7 +156,7 @@ 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.bind(port[, address]\[, callback]) +### socket.bind(port[, address][, callback]) * `port` Integer * `address` String, Optional |