blob: 8b78bd66c6f313a4f83b0f52e9e8792d485c655e [file] [log] [blame]
Roman Reissf29762f2015-05-19 11:00:061'use strict';
Ben Noordhuis9e32c2e2012-12-31 16:42:542var common = require('../common');
3var assert = require('assert');
4var dgram = require('dgram');
5
6var source = dgram.createSocket('udp4');
7var target = dgram.createSocket('udp4');
8var messages = 0;
9
10process.on('exit', function() {
11 assert.equal(messages, 2);
12});
13
14target.on('message', function(buf) {
15 if (buf.toString() === 'abc') ++messages;
16 if (buf.toString() === 'def') ++messages;
17 if (messages === 2) {
18 source.close();
19 target.close();
20 }
21});
22
23target.on('listening', function() {
24 // Second .send() call should not throw a bind error.
25 source.send(Buffer('abc'), 0, 3, common.PORT, '127.0.0.1');
26 source.send(Buffer('def'), 0, 3, common.PORT, '127.0.0.1');
27});
28
29target.bind(common.PORT);