~ubuntu-branches/ubuntu/trusty/nodejs/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/api/all.html

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-12-12 23:04:07 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20131212230407-xfa6gka4c6oatsx1
Tags: 0.10.23~dfsg1-1
* Upstream update.
* Refresh patches, remove 1005 patch, applied upstream.

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>About this Documentation Node.js v0.10.22 Manual &amp; Documentation</title>
 
5
  <title>About this Documentation Node.js v0.10.23 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/all.html">
31
31
 
32
32
        <div id="column1" class="interior">
33
33
          <header>
34
 
            <h1>Node.js v0.10.22 Manual &amp; Documentation</h1>
 
34
            <h1>Node.js v0.10.23 Manual &amp; Documentation</h1>
35
35
            <div id="gtoc">
36
36
              <p>
37
37
                <a href="index.html" name="toc">Index</a> |
314
314
<li><a href="#all_event_finish">Event: &#39;finish&#39;</a></li>
315
315
<li><a href="#all_event_pipe">Event: &#39;pipe&#39;</a></li>
316
316
<li><a href="#all_event_unpipe">Event: &#39;unpipe&#39;</a></li>
 
317
<li><a href="#all_event_error_1">Event: &#39;error&#39;</a></li>
317
318
</ul>
318
319
</li>
319
320
<li><a href="#all_class_stream_duplex">Class: stream.Duplex</a></li>
564
565
<li><a href="#all_class_fs_fswatcher">Class: fs.FSWatcher</a><ul>
565
566
<li><a href="#all_watcher_close">watcher.close()</a></li>
566
567
<li><a href="#all_event_change">Event: &#39;change&#39;</a></li>
567
 
<li><a href="#all_event_error_1">Event: &#39;error&#39;</a></li>
 
568
<li><a href="#all_event_error_2">Event: &#39;error&#39;</a></li>
568
569
</ul>
569
570
</li>
570
571
</ul>
603
604
<li><a href="#all_event_listening">Event: &#39;listening&#39;</a></li>
604
605
<li><a href="#all_event_connection">Event: &#39;connection&#39;</a></li>
605
606
<li><a href="#all_event_close_1">Event: &#39;close&#39;</a></li>
606
 
<li><a href="#all_event_error_2">Event: &#39;error&#39;</a></li>
 
607
<li><a href="#all_event_error_3">Event: &#39;error&#39;</a></li>
607
608
</ul>
608
609
</li>
609
610
<li><a href="#all_class_net_socket">Class: net.Socket</a><ul>
634
635
<li><a href="#all_event_end_1">Event: &#39;end&#39;</a></li>
635
636
<li><a href="#all_event_timeout">Event: &#39;timeout&#39;</a></li>
636
637
<li><a href="#all_event_drain_1">Event: &#39;drain&#39;</a></li>
637
 
<li><a href="#all_event_error_3">Event: &#39;error&#39;</a></li>
 
638
<li><a href="#all_event_error_4">Event: &#39;error&#39;</a></li>
638
639
<li><a href="#all_event_close_2">Event: &#39;close&#39;</a></li>
639
640
</ul>
640
641
</li>
649
650
<li><a href="#all_event_message">Event: &#39;message&#39;</a></li>
650
651
<li><a href="#all_event_listening_1">Event: &#39;listening&#39;</a></li>
651
652
<li><a href="#all_event_close_3">Event: &#39;close&#39;</a></li>
652
 
<li><a href="#all_event_error_4">Event: &#39;error&#39;</a></li>
 
653
<li><a href="#all_event_error_5">Event: &#39;error&#39;</a></li>
653
654
<li><a href="#all_socket_send_buf_offset_length_port_address_callback">socket.send(buf, offset, length, port, address, [callback])</a></li>
654
655
<li><a href="#all_socket_bind_port_address_callback">socket.bind(port, [address], [callback])</a></li>
655
656
<li><a href="#all_socket_close">socket.close()</a></li>
703
704
</li>
704
705
<li><a href="#all_class_http_serverresponse">Class: http.ServerResponse</a><ul>
705
706
<li><a href="#all_event_close_5">Event: &#39;close&#39;</a></li>
 
707
<li><a href="#all_event_finish_1">Event: &#39;finish&#39;</a></li>
706
708
<li><a href="#all_response_writecontinue">response.writeContinue()</a></li>
707
709
<li><a href="#all_response_writehead_statuscode_reasonphrase_headers">response.writeHead(statusCode, [reasonPhrase], [headers])</a></li>
708
710
<li><a href="#all_response_settimeout_msecs_callback">response.setTimeout(msecs, callback)</a></li>
717
719
<li><a href="#all_response_end_data_encoding">response.end([data], [encoding])</a></li>
718
720
</ul>
719
721
</li>
720
 
<li><a href="#all_http_request_options_callback">http.request(options, callback)</a></li>
721
 
<li><a href="#all_http_get_options_callback">http.get(options, callback)</a></li>
 
722
<li><a href="#all_http_request_options_callback">http.request(options, [callback])</a></li>
 
723
<li><a href="#all_http_get_options_callback">http.get(options, [callback])</a></li>
722
724
<li><a href="#all_class_http_agent">Class: http.Agent</a><ul>
723
725
<li><a href="#all_agent_maxsockets">agent.maxSockets</a></li>
724
726
<li><a href="#all_agent_sockets">agent.sockets</a></li>
848
850
</li>
849
851
<li><a href="#all_child_process">Child Process</a><ul>
850
852
<li><a href="#all_class_childprocess">Class: ChildProcess</a><ul>
851
 
<li><a href="#all_event_error_5">Event:  &#39;error&#39;</a></li>
 
853
<li><a href="#all_event_error_6">Event:  &#39;error&#39;</a></li>
852
854
<li><a href="#all_event_exit_2">Event:  &#39;exit&#39;</a></li>
853
855
<li><a href="#all_event_close_8">Event: &#39;close&#39;</a></li>
854
856
<li><a href="#all_event_disconnect">Event: &#39;disconnect&#39;</a></li>
995
997
<li><a href="#all_event_listening_3">Event: &#39;listening&#39;</a></li>
996
998
<li><a href="#all_event_disconnect_2">Event: &#39;disconnect&#39;</a></li>
997
999
<li><a href="#all_event_exit_4">Event: &#39;exit&#39;</a></li>
998
 
<li><a href="#all_event_error_6">Event: &#39;error&#39;</a></li>
 
1000
<li><a href="#all_event_error_7">Event: &#39;error&#39;</a></li>
999
1001
</ul>
1000
1002
</li>
1001
1003
</ul>
3077
3079
See kill(2) for more information.
3078
3080
 
3079
3081
</p>
 
3082
<p>Will throw an error if target does not exist, and as a special case, a signal of
 
3083
<code>0</code> can be used to test for the existence of a process.
 
3084
 
 
3085
</p>
3080
3086
<p>Note that just because the name of this function is <code>process.kill</code>, it is
3081
3087
really just a signal sender, like the <code>kill</code> system call.  The signal sent
3082
3088
may do something other than kill the target process.
3095
3101
}, 100);
3096
3102
 
3097
3103
process.kill(process.pid, &#39;SIGHUP&#39;);</code></pre>
3098
 
<p>Note: SIGUSR1 is reserved by node.js.  It can be used to kickstart the
3099
 
debugger.
 
3104
<p>Note: When SIGUSR1 is received by Node.js it starts the debugger, see
 
3105
<a href="#process_signal_events">Signal Events</a>.
3100
3106
 
3101
3107
</p>
3102
3108
<h2>process.pid<span><a class="mark" href="#all_process_pid" id="all_process_pid">#</a></span></h2>
5385
5391
  writer.write(&#39;hello, #&#39; + i + &#39;!\n&#39;);
5386
5392
}
5387
5393
writer.end(&#39;this is the end\n&#39;);
5388
 
write.on(&#39;finish&#39;, function() {
 
5394
writer.on(&#39;finish&#39;, function() {
5389
5395
  console.error(&#39;all writes are now complete.&#39;);
5390
5396
});</code></pre>
5391
5397
<h4>Event: &#39;pipe&#39;<span><a class="mark" href="#all_event_pipe" id="all_event_pipe">#</a></span></h4>
5419
5425
});
5420
5426
reader.pipe(writer);
5421
5427
reader.unpipe(writer);</code></pre>
 
5428
<h4>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_1" id="all_event_error_1">#</a></span></h4>
 
5429
<p>Emitted if there was an error when writing or piping data.
 
5430
 
 
5431
</p>
5422
5432
<h3>Class: stream.Duplex<span><a class="mark" href="#all_class_stream_duplex" id="all_class_stream_duplex">#</a></span></h3>
5423
5433
<p>Duplex streams are streams that implement both the <a href="#stream_class_stream_readable">Readable</a> and
5424
5434
<a href="#stream_class_stream_writable">Writable</a> interfaces.  See above for usage.
6428
6438
<h3>hash.update(data, [input_encoding])<span><a class="mark" href="#all_hash_update_data_input_encoding" id="all_hash_update_data_input_encoding">#</a></span></h3>
6429
6439
<p>Updates the hash content with the given <code>data</code>, the encoding of which
6430
6440
is given in <code>input_encoding</code> and can be <code>&#39;utf8&#39;</code>, <code>&#39;ascii&#39;</code> or
6431
 
<code>&#39;binary&#39;</code>.  If no encoding is provided, then a buffer is expected.
6432
 
If <code>data</code> is a <code>Buffer</code> then <code>input_encoding</code> is ignored.
 
6441
<code>&#39;binary&#39;</code>.  If no encoding is provided and the input is a string an
 
6442
encoding of <code>&#39;binary&#39;</code> is enforced. If <code>data</code> is a <code>Buffer</code> then
 
6443
<code>input_encoding</code> is ignored.
6433
6444
 
6434
6445
</p>
6435
6446
<p>This can be called many times with new data as it is streamed.
6823
6834
  console.log(&#39;Have %d bytes of random data: %s&#39;, buf.length, buf);
6824
6835
} catch (ex) {
6825
6836
  // handle error
 
6837
  // most likely, entropy sources are drained
6826
6838
}</code></pre>
 
6839
<p>NOTE: Will throw error or invoke callback with error, if there is not enough
 
6840
accumulated entropy to generate cryptographically strong data. In other words,
 
6841
<code>crypto.randomBytes</code> without callback will not block even if all entropy sources
 
6842
are drained.
 
6843
 
 
6844
</p>
6827
6845
<h2>crypto.pseudoRandomBytes(size, [callback])<span><a class="mark" href="#all_crypto_pseudorandombytes_size_callback" id="all_crypto_pseudorandombytes_size_callback">#</a></span></h2>
6828
6846
<p>Generates <em>non</em>-cryptographically strong pseudo-random data. The data
6829
6847
returned will be unique if it is sufficiently long, but is not
8270
8288
See more details in <a href="#fs_fs_watch_filename_options_listener">fs.watch</a>.
8271
8289
 
8272
8290
</p>
8273
 
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_1" id="all_event_error_1">#</a></span></h3>
 
8291
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_2" id="all_event_error_2">#</a></span></h3>
8274
8292
<div class="signature"><ul>
8275
8293
<li><code>error</code> <span class="type">Error object</span></li>
8276
8294
</div></ul>
8566
8584
changed to
8567
8585
 
8568
8586
</p>
8569
 
<pre><code>var client = net.connect({path: &#39;/tmp/echo.sock&#39;},</code></pre>
 
8587
<pre><code>var client = net.connect({path: &#39;/tmp/echo.sock&#39;});</code></pre>
8570
8588
<h2>net.connect(port, [host], [connectListener])<span><a class="mark" href="#all_net_connect_port_host_connectlistener" id="all_net_connect_port_host_connectlistener">#</a></span></h2>
8571
8589
<h2>net.createConnection(port, [host], [connectListener])<span><a class="mark" href="#all_net_createconnection_port_host_connectlistener" id="all_net_createconnection_port_host_connectlistener">#</a></span></h2>
8572
8590
<p>Creates a TCP connection to <code>port</code> on <code>host</code>. If <code>host</code> is omitted,
8743
8761
event is not emitted until all connections are ended.
8744
8762
 
8745
8763
</p>
8746
 
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_2" id="all_event_error_2">#</a></span></h3>
 
8764
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_3" id="all_event_error_3">#</a></span></h3>
8747
8765
<div class="signature"><ul>
8748
8766
<li><span class="type">Error Object</span></li>
8749
8767
</div></ul>
8766
8784
 
8767
8785
</p>
8768
8786
<pre><code>{ fd: null
8769
 
  type: null
8770
 
  allowHalfOpen: false
 
8787
  allowHalfOpen: false,
 
8788
  readable: false,
 
8789
  writable: false
8771
8790
}</code></pre>
8772
 
<p><code>fd</code> allows you to specify the existing file descriptor of socket. <code>type</code>
8773
 
specified underlying protocol. It can be <code>&#39;tcp4&#39;</code>, <code>&#39;tcp6&#39;</code>, or <code>&#39;unix&#39;</code>.
 
8791
<p><code>fd</code> allows you to specify the existing file descriptor of socket.
 
8792
Set <code>readable</code> and/or <code>writable</code> to <code>true</code> to allow reads and/or writes on this
 
8793
socket (NOTE: Works only when <code>fd</code> is passed).
8774
8794
About <code>allowHalfOpen</code>, refer to <code>createServer()</code> and <code>&#39;end&#39;</code> event.
8775
8795
 
8776
8796
</p>
8993
9013
<p>See also: the return values of <code>socket.write()</code>
8994
9014
 
8995
9015
</p>
8996
 
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_3" id="all_event_error_3">#</a></span></h3>
 
9016
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_4" id="all_event_error_4">#</a></span></h3>
8997
9017
<div class="signature"><ul>
8998
9018
<li><span class="type">Error object</span></li>
8999
9019
</div></ul>
9088
9108
on this socket.
9089
9109
 
9090
9110
</p>
9091
 
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_4" id="all_event_error_4">#</a></span></h3>
 
9111
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_5" id="all_event_error_5">#</a></span></h3>
9092
9112
<div class="signature"><ul>
9093
9113
<li><code>exception</code> Error object</li>
9094
9114
</div></ul>
9308
9328
<pre class="api_stability_3">Stability: 3 - Stable</pre><p>Use <code>require(&#39;dns&#39;)</code> to access this module. All methods in the dns module
9309
9329
use C-Ares except for <code>dns.lookup</code> which uses <code>getaddrinfo(3)</code> in a thread
9310
9330
pool. C-Ares is much faster than <code>getaddrinfo</code> but the system resolver is
9311
 
more constant with how other programs operate. When a user does
 
9331
more consistent with how other programs operate. When a user does
9312
9332
<code>net.connect(80, &#39;google.com&#39;)</code> or <code>http.get({ host: &#39;google.com&#39; })</code> the
9313
9333
<code>dns.lookup</code> method is used. Users who need to do a large number of lookups
9314
9334
quickly should use the methods that go through C-Ares.
9728
9748
<a href="#http_response_end_data_encoding">response.end()</a> was called or able to flush.
9729
9749
 
9730
9750
</p>
 
9751
<h3>Event: &#39;finish&#39;<span><a class="mark" href="#all_event_finish_1" id="all_event_finish_1">#</a></span></h3>
 
9752
<p><code>function () { }</code>
 
9753
 
 
9754
</p>
 
9755
<p>Emitted when the response has been sent. More specifically, this event is
 
9756
emitted when the last segment of the response headers and body have been
 
9757
handed off to the operating system for transmission over the network. It
 
9758
does not imply that the client has received anything yet.
 
9759
 
 
9760
</p>
 
9761
<p>After this event, no more events will be emitted on the response object.
 
9762
 
 
9763
</p>
9731
9764
<h3>response.writeContinue()<span><a class="mark" href="#all_response_writecontinue" id="all_response_writecontinue">#</a></span></h3>
9732
9765
<p>Sends a HTTP/1.1 100 Continue message to the client, indicating that
9733
9766
the request body should be sent. See the <a href="#http_event_checkcontinue">&#39;checkContinue&#39;</a> event on <code>Server</code>.
9900
9933
 
9901
9934
 
9902
9935
</p>
9903
 
<h2>http.request(options, callback)<span><a class="mark" href="#all_http_request_options_callback" id="all_http_request_options_callback">#</a></span></h2>
 
9936
<h2>http.request(options, [callback])<span><a class="mark" href="#all_http_request_options_callback" id="all_http_request_options_callback">#</a></span></h2>
9904
9937
<p>Node maintains several connections per server to make HTTP requests.
9905
9938
This function allows one to transparently issue requests.
9906
9939
 
9934
9967
</ul>
9935
9968
</li>
9936
9969
</ul>
 
9970
<p>The optional <code>callback</code> parameter will be added as a one time listener for
 
9971
the <a href="#http_event_response">&#39;response&#39;</a> event.
 
9972
 
 
9973
</p>
9937
9974
<p><code>http.request()</code> returns an instance of the <a href="#http_class_http_clientrequest">http.ClientRequest</a>
9938
9975
class. The <code>ClientRequest</code> instance is a writable stream. If one needs to
9939
9976
upload a file with a POST request, then write to the <code>ClientRequest</code> object.
9994
10031
to compute basic authentication.</p>
9995
10032
</li>
9996
10033
</ul>
9997
 
<h2>http.get(options, callback)<span><a class="mark" href="#all_http_get_options_callback" id="all_http_get_options_callback">#</a></span></h2>
 
10034
<h2>http.get(options, [callback])<span><a class="mark" href="#all_http_get_options_callback" id="all_http_get_options_callback">#</a></span></h2>
9998
10035
<p>Since most requests are GET requests without bodies, Node provides this
9999
10036
convenience method. The only difference between this method and <code>http.request()</code>
10000
10037
is that it sets the method to GET and calls <code>req.end()</code> automatically.
11590
11627
<code>spawn()</code> or <code>fork()</code> methods to create a Child Process instance.
11591
11628
 
11592
11629
</p>
11593
 
<h3>Event:  &#39;error&#39;<span><a class="mark" href="#all_event_error_5" id="all_event_error_5">#</a></span></h3>
 
11630
<h3>Event:  &#39;error&#39;<span><a class="mark" href="#all_event_error_6" id="all_event_error_6">#</a></span></h3>
11594
11631
<div class="signature"><ul>
11595
11632
<li><code>err</code> <span class="type">Error Object</span> the error.</li>
11596
11633
</div></ul>
11602
11639
<li>The process could not be killed, or</li>
11603
11640
<li>Sending a message to the child process failed for whatever reason.</li>
11604
11641
</ol>
 
11642
<p>Note that the <code>exit</code>-event may or may not fire after an error has occured. If
 
11643
you are listening on both events to fire a function, remember to guard against
 
11644
calling your function twice.
 
11645
 
 
11646
</p>
11605
11647
<p>See also <a href="#child_process_child_kill_signal"><code>ChildProcess#kill()</code></a> and
11606
11648
<a href="#child_process_child_send_message_sendhandle"><code>ChildProcess#send()</code></a>.
11607
11649
 
12166
12208
<li><code>env</code> <span class="type">Object</span> Environment key-value pairs</li>
12167
12209
<li><code>encoding</code> <span class="type">String</span> (Default: &#39;utf8&#39;)</li>
12168
12210
<li><code>execPath</code> <span class="type">String</span> Executable used to create the child process</li>
 
12211
<li><code>execArgv</code> <span class="type">Array</span> List of string arguments passed to the executable
 
12212
(Default: <code>process.execArgv</code>)</li>
12169
12213
<li><code>silent</code> <span class="type">Boolean</span> If true, prevent stdout and stderr in the spawned node
12170
12214
process from being associated with the parent&#39;s (default is false)</li>
12171
12215
</ul>
13143
13187
<h2>cluster.settings<span><a class="mark" href="#all_cluster_settings" id="all_cluster_settings">#</a></span></h2>
13144
13188
<div class="signature"><ul>
13145
13189
<li><span class="type">Object</span><ul>
 
13190
<li><code>execArgv</code> <span class="type">Array</span> list of string arguments passed to the node executable. 
 
13191
(Default=<code>process.execArgv</code>)</li>
13146
13192
<li><code>exec</code> <span class="type">String</span> file path to worker file.  (Default=<code>process.argv[1]</code>)</li>
13147
13193
<li><code>args</code> <span class="type">Array</span> string arguments passed to worker.
13148
13194
(Default=<code>process.argv.slice(2)</code>)</li>
13662
13708
    console.log(&quot;worker success!&quot;);
13663
13709
  }
13664
13710
});</code></pre>
13665
 
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_6" id="all_event_error_6">#</a></span></h3>
 
13711
<h3>Event: &#39;error&#39;<span><a class="mark" href="#all_event_error_7" id="all_event_error_7">#</a></span></h3>
13666
13712
<p>This event is the same as the one provided by <code>child_process.fork()</code>.
13667
13713
 
13668
13714
</p>
13688
13734
            <li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
13689
13735
        </ul>
13690
13736
 
13691
 
        <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>
 
13737
        <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.23/LICENSE">license</a>.</p>
13692
13738
    </div>
13693
13739
 
13694
13740
  <script src="../sh_main.js"></script>