mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 11:29:35 +00:00

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
24 lines
774 B
JavaScript
24 lines
774 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
var dgram = require('dgram');
|
|
|
|
var buf = Buffer('test');
|
|
var host = '127.0.0.1';
|
|
var sock = dgram.createSocket('udp4');
|
|
|
|
assert.throws(function() {
|
|
sock.send();
|
|
}, TypeError); // First argument should be a buffer.
|
|
|
|
// send(buf, offset, length, port, host)
|
|
assert.throws(function() { sock.send(buf, 1, 1, -1, host); }, RangeError);
|
|
assert.throws(function() { sock.send(buf, 1, 1, 0, host); }, RangeError);
|
|
assert.throws(function() { sock.send(buf, 1, 1, 65536, host); }, RangeError);
|
|
|
|
// send(buf, port, host)
|
|
assert.throws(function() { sock.send(23, 12345, host); }, TypeError);
|
|
|
|
// send([buf1, ..], port, host)
|
|
assert.throws(function() { sock.send([buf, 23], 12345, host); }, TypeError);
|