Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dgram: change parameter name in set(Multicast)TTL #13747

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,35 +524,35 @@ Socket.prototype.setBroadcast = function(arg) {
};


Socket.prototype.setTTL = function(arg) {
if (typeof arg !== 'number') {
Socket.prototype.setTTL = function(ttl) {
if (typeof ttl !== 'number') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
'arg',
'ttl',
'number');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding the actual argument?

}

var err = this._handle.setTTL(arg);
var err = this._handle.setTTL(ttl);
if (err) {
throw errnoException(err, 'setTTL');
}

return arg;
return ttl;
};


Socket.prototype.setMulticastTTL = function(arg) {
if (typeof arg !== 'number') {
Socket.prototype.setMulticastTTL = function(ttl) {
if (typeof ttl !== 'number') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
'arg',
'ttl',
'number');
}

var err = this._handle.setMulticastTTL(arg);
var err = this._handle.setMulticastTTL(ttl);
if (err) {
throw errnoException(err, 'setMulticastTTL');
}

return arg;
return ttl;
};


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-multicast-setTTL.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ socket.on('listening', common.mustCall(() => {
}, common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "arg" argument must be of type number$/
message: /^The "ttl" argument must be of type number$/
}));

//close the socket
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-setTTL.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ socket.on('listening', common.mustCall(() => {
}, common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "arg" argument must be of type number$/
message: /^The "ttl" argument must be of type number$/
}));

// TTL must be a number from > 0 to < 256
Expand Down