Test that an error is thrown when bind() is called on an already bound socket. PR-URL: https://github.com/nodejs/node/pull/10894 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
18 lines
433 B
JavaScript
18 lines
433 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const dgram = require('dgram');
|
|
|
|
var socket = dgram.createSocket('udp4');
|
|
|
|
socket.on('listening', common.mustCall(() => {
|
|
assert.throws(() => {
|
|
socket.bind();
|
|
}, /^Error: Socket is already bound$/);
|
|
|
|
socket.close();
|
|
}));
|
|
|
|
var result = socket.bind(); // should not throw
|
|
|
|
assert.strictEqual(result, socket); // should have returned itself
|