1 var common = require('../common');
2 var assert = require('assert');
3 var dgram = require('dgram');
6 var socket_ipv4 = dgram.createSocket('udp4');
8 socket_ipv4.on('listening', assert.fail);
10 socket_ipv4.on('error', common.mustCall(function(e) {
11 assert.equal(e.message, 'bind EADDRNOTAVAIL 1.1.1.1:' + common.PORT);
12 assert.equal(e.address, '1.1.1.1');
13 assert.equal(e.port, common.PORT);
14 assert.equal(e.code, 'EADDRNOTAVAIL');
18 socket_ipv4.bind(common.PORT, '1.1.1.1');
21 var socket_ipv6 = dgram.createSocket('udp6');
22 var family_ipv6 = 'IPv6';
24 socket_ipv6.on('listening', assert.fail);
26 socket_ipv6.on('error', common.mustCall(function(e) {
27 // EAFNOSUPPORT means IPv6 is disabled on this system.
28 var code = (e.code === 'EADDRNOTAVAIL' ? e.code : 'EAFNOSUPPORT');
29 assert.equal(e.message, 'bind ' + code + ' 111::1:' + common.PORT);
30 assert.equal(e.address, '111::1');
31 assert.equal(e.port, common.PORT);
32 assert.equal(e.code, code);
36 socket_ipv6.bind(common.PORT, '111::1');