Skip to content

Instantly share code, notes, and snippets.

@m4tty
Created July 26, 2012 22:29
Show Gist options
  • Save m4tty/3184975 to your computer and use it in GitHub Desktop.
Save m4tty/3184975 to your computer and use it in GitHub Desktop.
node.js dgram socket send doesn't work from within process.on('xxxx')
var http = require("http");
var dgram = require('dgram');
process.on('uncaughtException', function(err) {
console.log(err);
var message = new Buffer("bad things happened uncaughtException");
var client3 = dgram.createSocket("udp4");
client3.send(message, 0, message.length, 514, "127.0.0.1");
process.exit(1);
});
process.on('SIGINT', function(err) {
console.log('in SIGINT');
var message = new Buffer("Some bytes sigint");
var client2 = dgram.createSocket("udp4");
client2.send(message, 0, message.length, 514, "127.0.0.1");
process.exit(1);
});
console.log('in main');
var message = new Buffer("in main");
var client1 = dgram.createSocket("udp4");
client1.send(message, 0, message.length, 514, "127.0.0.1");
http.createServer(function(request, response) {
throw new Error('some error');
}).listen(3003);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment