~ubuntu-branches/ubuntu/vivid/nodejs/vivid

« back to all changes in this revision

Viewing changes to doc/api/dgram.markdown

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-11-13 23:17:51 UTC
  • mfrom: (1.1.29)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20131113231751-m6uqywp5dc4s4fxo
Tags: 0.10.22~dfsg1-1
* Upstream update. 
* Refresh patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
* `buf` Buffer object.  Message to be sent
73
73
* `offset` Integer. Offset in the buffer where the message starts.
74
74
* `length` Integer. Number of bytes in the message.
75
 
* `port` Integer. destination port
76
 
* `address` String. destination IP
77
 
* `callback` Function. Callback when message is done being delivered.
78
 
  Optional.
79
 
 
80
 
For UDP sockets, the destination port and IP address must be specified.  A string
81
 
may be supplied for the `address` parameter, and it will be resolved with DNS.  An
82
 
optional callback may be specified to detect any DNS errors and when `buf` may be
83
 
re-used.  Note that DNS lookups will delay the time that a send takes place, at
84
 
least until the next tick.  The only way to know for sure that a send has taken place
85
 
is to use the callback.
86
 
 
87
 
If the socket has not been previously bound with a call to `bind`, it's
88
 
assigned a random port number and bound to the "all interfaces" address
89
 
(0.0.0.0 for `udp4` sockets, ::0 for `udp6` sockets).
 
75
* `port` Integer. Destination port.
 
76
* `address` String. Destination hostname or IP address.
 
77
* `callback` Function. Called when the message has been sent. Optional.
 
78
 
 
79
For UDP sockets, the destination port and address must be specified.  A string
 
80
may be supplied for the `address` parameter, and it will be resolved with DNS.
 
81
 
 
82
If the address is omitted or is an empty string, `'0.0.0.0'` or `'::0'` is used
 
83
instead.  Depending on the network configuration, those defaults may or may not
 
84
work; it's best to be explicit about the destination address.
 
85
 
 
86
If the socket has not been previously bound with a call to `bind`, it gets
 
87
assigned a random port number and is bound to the "all interfaces" address
 
88
(`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
 
89
 
 
90
An optional callback may be specified to detect DNS errors or for determining
 
91
when it's safe to reuse the `buf` object.  Note that DNS lookups delay the time
 
92
to send for at least one tick.  The only way to know for sure that the datagram
 
93
has been sent is by using a callback.
90
94
 
91
95
Example of sending a UDP packet to a random port on `localhost`;
92
96