Skip to content
This repository
Browse code

dgram: pass the bytes sent to the send callback

Fixes #6953
  • Loading branch information...
commit a4436bab7b83e311f8a4207b9c6d97acde4735ff 1 parent 3421d29
Timothy J Fontaine tjfontaine authored

Showing 2 changed files with 32 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/dgram.js
  2. +31 0 test/simple/test-dgram-bytes-length.js
2  lib/dgram.js
@@ -319,7 +319,7 @@ Socket.prototype.send = function(buffer,
319 319
320 320
321 321 function afterSend(err) {
322   - this.callback(err ? errnoException(err, 'send') : null);
  322 + this.callback(err ? errnoException(err, 'send') : null, this.buffer.length);
323 323 }
324 324
325 325
31 test/simple/test-dgram-bytes-length.js
... ... @@ -0,0 +1,31 @@
  1 +// Copyright Joyent, Inc. and other Node contributors.
  2 +//
  3 +// Permission is hereby granted, free of charge, to any person obtaining a
  4 +// copy of this software and associated documentation files (the
  5 +// "Software"), to deal in the Software without restriction, including
  6 +// without limitation the rights to use, copy, modify, merge, publish,
  7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
  8 +// persons to whom the Software is furnished to do so, subject to the
  9 +// following conditions:
  10 +//
  11 +// The above copyright notice and this permission notice shall be included
  12 +// in all copies or substantial portions of the Software.
  13 +//
  14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
  21 +
  22 +var common = require('../common');
  23 +var assert = require('assert');
  24 +var dgram = require('dgram');
  25 +
  26 +var message = new Buffer('Some bytes');
  27 +var client = dgram.createSocket('udp4');
  28 +client.send(message, 0, message.length, 41234, "localhost", function(err, bytes) {
  29 + assert.strictEqual(bytes, message.length);
  30 + client.close();
  31 +});

0 comments on commit a4436ba

Please sign in to comment.
Something went wrong with that request. Please try again.