1// Flags: --expose-internals 2'use strict'; 3const common = require('../common'); 4const assert = require('assert'); 5const dgram = require('dgram'); 6const { kStateSymbol } = require('internal/dgram'); 7const s = dgram.createSocket('udp4'); 8const { handle } = s[kStateSymbol]; 9 10s.on('error', common.mustCall((err) => { 11 s.close(); 12 13 // Don't check the full error message, as the errno is not important here. 14 assert.match(String(err), /^Error: recvmsg/); 15 assert.strictEqual(err.syscall, 'recvmsg'); 16})); 17 18s.on('message', common.mustNotCall('no message should be received.')); 19s.bind(common.mustCall(() => handle.onmessage(-1, handle, null, null))); 20