lib/snmp.js
function Session(options) {
    var self = this;

    self.options = options || {};
    defaults(self.options, exports.defaultOptions);

    self.reqs = {};
    self.socket = dgram.createSocket(self.options.family);
    self.socket.on('message', msgReceived.bind(self));
    self.socket.on('close', function () {
        // Remove the socket so we don't try to send a message on
        // it when it's closed.
        self.socket = undefined;
    });
    self.socket.on('error', function () {
        // Errors will be emitted here as well as on the callback to the send function.
        // We handle them there, so doing anything here is unnecessary.
        // But having no error handler trips up the test suite.
    });
    // If exclusive is false (default), then cluster workers will use the same underlying handle,
    // allowing connection handling duties to be shared.
    // When exclusive is true, the handle is not shared, and attempted port sharing results in an error.
    self.socket.bind({
        port: 0, //get a random port automatically
        exclusive: true // you should not share the same port, otherwise yours packages will be screwed up between workers
    });
}
function Session(options) {
    var self = this;

    self.options = options || {};
    defaults(self.options, exports.defaultOptions);

    self.reqs = {};
    self.socket = dgram.createSocket(self.options.family);
    self.socket.on('message', msgReceived.bind(self));
    self.socket.on('close', function () {
        // Remove the socket so we don't try to send a message on
        // it when it's closed.
        self.socket = undefined;
    });
    self.socket.on('error', function () {
        // Errors will be emitted here as well as on the callback to the send function.
        // We handle them there, so doing anything here is unnecessary.
        // But having no error handler trips up the test suite.
    });
    // If exclusive is false (default), then cluster workers will use the same underlying handle,
    // allowing connection handling duties to be shared.
    // When exclusive is true, the handle is not shared, and attempted port sharing results in an error.
    self.socket.bind({
        port: 0, //get a random port automatically
        exclusive: true // you should not share the same port, otherwise yours packages will be screwed up between workers
    });
}
This creates a new SNMP session.