Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo<Value>& args) {

if (!args[0]->IsInt32()) {
if (args[1].As<Uint32>()->Value() == 0)
return env->ThrowUVException(EINVAL, "uv_recv_buffer_size");
return env->ThrowUVException(UV_EINVAL, "uv_recv_buffer_size");
else
return env->ThrowUVException(EINVAL, "uv_send_buffer_size");
return env->ThrowUVException(UV_EINVAL, "uv_send_buffer_size");
}

int err;
Expand Down
21 changes: 21 additions & 0 deletions test/parallel/test-dgram-socket-buffer-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,24 @@ const dgram = require('dgram');
socket.close();
}));
}

function checkBufferSizeError(type, size) {
const errorObj = {
code: 'ERR_SOCKET_BUFFER_SIZE',
type: Error,
message: 'Could not get or set buffer size: Error: EINVAL: ' +
`invalid argument, uv_${type}_buffer_size`
};
const functionName = `set${type.charAt(0).toUpperCase()}${type.slice(1)}` +
'BufferSize';
const socket = dgram.createSocket('udp4');
socket.bind(common.mustCall(() => {
assert.throws(() => {
socket[functionName](size);
}, common.expectsError(errorObj));
socket.close();
}));
}

checkBufferSizeError('recv', 2147483648);
checkBufferSizeError('send', 2147483648);