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

« back to all changes in this revision

Viewing changes to doc/api/dgram.html

  • 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:
2
2
<html lang="en">
3
3
<head>
4
4
  <meta charset="utf-8">
5
 
  <title>UDP / Datagram Sockets Node.js v0.10.21 Manual &amp; Documentation</title>
 
5
  <title>UDP / Datagram Sockets Node.js v0.10.22 Manual &amp; Documentation</title>
6
6
  <link rel="stylesheet" href="assets/style.css">
7
7
  <link rel="stylesheet" href="assets/sh.css">
8
8
  <link rel="canonical" href="http://nodejs.org/api/dgram.html">
31
31
 
32
32
        <div id="column1" class="interior">
33
33
          <header>
34
 
            <h1>Node.js v0.10.21 Manual &amp; Documentation</h1>
 
34
            <h1>Node.js v0.10.22 Manual &amp; Documentation</h1>
35
35
            <div id="gtoc">
36
36
              <p>
37
37
                <a href="index.html" name="toc">Index</a> |
149
149
<li><code>buf</code> Buffer object.  Message to be sent</li>
150
150
<li><code>offset</code> Integer. Offset in the buffer where the message starts.</li>
151
151
<li><code>length</code> Integer. Number of bytes in the message.</li>
152
 
<li><code>port</code> Integer. destination port</li>
153
 
<li><code>address</code> String. destination IP</li>
154
 
<li><code>callback</code> Function. Callback when message is done being delivered.
155
 
Optional.</li>
 
152
<li><code>port</code> Integer. Destination port.</li>
 
153
<li><code>address</code> String. Destination hostname or IP address.</li>
 
154
<li><code>callback</code> Function. Called when the message has been sent. Optional.</li>
156
155
</div></ul>
157
 
<p>For UDP sockets, the destination port and IP address must be specified.  A string
158
 
may be supplied for the <code>address</code> parameter, and it will be resolved with DNS.  An
159
 
optional callback may be specified to detect any DNS errors and when <code>buf</code> may be
160
 
re-used.  Note that DNS lookups will delay the time that a send takes place, at
161
 
least until the next tick.  The only way to know for sure that a send has taken place
162
 
is to use the callback.
163
 
 
164
 
</p>
165
 
<p>If the socket has not been previously bound with a call to <code>bind</code>, it&#39;s
166
 
assigned a random port number and bound to the &quot;all interfaces&quot; address
167
 
(0.0.0.0 for <code>udp4</code> sockets, ::0 for <code>udp6</code> sockets).
 
156
<p>For UDP sockets, the destination port and address must be specified.  A string
 
157
may be supplied for the <code>address</code> parameter, and it will be resolved with DNS.
 
158
 
 
159
</p>
 
160
<p>If the address is omitted or is an empty string, <code>&#39;0.0.0.0&#39;</code> or <code>&#39;::0&#39;</code> is used
 
161
instead.  Depending on the network configuration, those defaults may or may not
 
162
work; it&#39;s best to be explicit about the destination address.
 
163
 
 
164
</p>
 
165
<p>If the socket has not been previously bound with a call to <code>bind</code>, it gets
 
166
assigned a random port number and is bound to the &quot;all interfaces&quot; address
 
167
(<code>&#39;0.0.0.0&#39;</code> for <code>udp4</code> sockets, <code>&#39;::0&#39;</code> for <code>udp6</code> sockets.)
 
168
 
 
169
</p>
 
170
<p>An optional callback may be specified to detect DNS errors or for determining
 
171
when it&#39;s safe to reuse the <code>buf</code> object.  Note that DNS lookups delay the time
 
172
to send for at least one tick.  The only way to know for sure that the datagram
 
173
has been sent is by using a callback.
168
174
 
169
175
</p>
170
176
<p>Example of sending a UDP packet to a random port on <code>localhost</code>;
365
371
            <li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
366
372
        </ul>
367
373
 
368
 
        <p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.10.21/LICENSE">license</a>.</p>
 
374
        <p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.10.22/LICENSE">license</a>.</p>
369
375
    </div>
370
376
 
371
377
  <script src="../sh_main.js"></script>