summaryrefslogtreecommitdiff
path: root/test/parallel/test-dgram-send-callback-buffer.js
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2016-01-29 14:18:27 +0100
committerMatteo Collina <hello@matteocollina.com>2016-01-29 19:26:44 +0100
commit137f53c7b72ff9cb36694d058136344076661f4a (patch)
treeb5dd2bad2463b37ff541726ad1f272e21920f212 /test/parallel/test-dgram-send-callback-buffer.js
parent4126441013bb569c19417f4a23c5f6b3bc38ef2b (diff)
downloadandroid-node-v8-137f53c7b72ff9cb36694d058136344076661f4a.tar.gz
android-node-v8-137f53c7b72ff9cb36694d058136344076661f4a.tar.bz2
android-node-v8-137f53c7b72ff9cb36694d058136344076661f4a.zip
dgram: support dgram.send with multiple buffers
Added ability to dgram.send to send multiple buffers, _writev style. The offset and length parameters in dgram.send are now optional. Refactored the dgram benchmarks, and seperated them from net. Added docs for the new signature. Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Fixes: https://github.com/nodejs/node/issues/4302 PR-URL: https://github.com/nodejs/node/pull/4374
Diffstat (limited to 'test/parallel/test-dgram-send-callback-buffer.js')
-rw-r--r--test/parallel/test-dgram-send-callback-buffer.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/parallel/test-dgram-send-callback-buffer.js b/test/parallel/test-dgram-send-callback-buffer.js
new file mode 100644
index 0000000000..1aea2f77ef
--- /dev/null
+++ b/test/parallel/test-dgram-send-callback-buffer.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+const dgram = require('dgram');
+
+const client = dgram.createSocket('udp4');
+
+const buf = new Buffer(256);
+
+const onMessage = common.mustCall(function(err, bytes) {
+ assert.equal(bytes, buf.length);
+ clearTimeout(timer);
+ client.close();
+});
+
+const timer = setTimeout(function() {
+ throw new Error('Timeout');
+}, common.platformTimeout(200));
+
+client.send(buf, common.PORT, common.localhostIPv4, onMessage);