shovon / node-rudp

Reliable UDP for Node.js
33 stars 14 forks source link

PendingPacket keeps going after client.close() #2

Open mvayngrib opened 9 years ago

mvayngrib commented 9 years ago

thanks for the great lib!

here's the breaking test:

var rudp = require('rudp');
var dgram = require('dgram');

var billSocket = dgram.createSocket('udp4');
var tedSocket = dgram.createSocket('udp4');
billSocket.bind(function() {
  tedSocket.bind(function() {
    var billClient = new rudp.Client(billSocket, '127.0.0.1', tedSocket.address().port);
    var tedClient = new rudp.Client(tedSocket, '127.0.0.1', billSocket.address().port);
    tedClient.on('data', function(data) {
      billClient.close()
      tedClient.close()
    })

    billClient.send(new Buffer('excellent!'))
  })
})

and here's the error stack trace:

dgram.js:439
    throw new Error('Not running'); // error message from dgram_legacy.js
          ^
Error: Not running
    at Socket._healthCheck (dgram.js:439:11)
    at Socket.send (dgram.js:282:8)
    at PacketSender.send (/Users/tenaciousmv/Code/node-rudp/lib/PacketSender.js:13:16)
    at null.<anonymous> (/Users/tenaciousmv/Code/node-rudp/lib/PendingPacket.js:23:24)
    at wrapper [as _onTimeout] (timers.js:287:14)
    at Timer.listOnTimeout (timers.js:133:15)