dgram: make setMulticastTTL() conform to v0.4 API

- throw if the ttl argument is not a number
- return the ttl argument (not particulary useful but it's what v0.4 did)

Note that the 0 < ttl < 256 check has *not* been reinstated. On Linux, -1 is a
valid argument to setsockopt(IPPROTO_IP, IP_TTL).
v0.7.4-release
Ben Noordhuis 2012-01-23 21:09:56 +01:00
parent f33a35e293
commit ed111975a0
1 changed files with 6 additions and 2 deletions

View File

@ -237,11 +237,15 @@ Socket.prototype.setTTL = function(arg) {
Socket.prototype.setMulticastTTL = function(arg) { Socket.prototype.setMulticastTTL = function(arg) {
if (this._handle.setMulticastTTL(arg) == -1) { if (typeof arg !== 'number') {
throw new TypeError('Argument must be a number');
}
if (this._handle.setMulticastTTL(arg)) {
throw errnoException(errno, 'setMulticastTTL'); throw errnoException(errno, 'setMulticastTTL');
} }
return true; return arg;
}; };