diff --git a/lib/poplib.js b/lib/poplib.js index 17a83ad..62464ee 100644 --- a/lib/poplib.js +++ b/lib/poplib.js @@ -100,9 +100,11 @@ function POP3Client(port, host, options) { var checkResp = true; var err = null; var detach = function() { + if (socket !== null) { socket.removeAllListeners("data"); socket.removeAllListeners("error"); socket.removeAllListeners("close"); + } }; socket.on("data", function(data) { @@ -640,4 +642,4 @@ POP3Client.prototype.quit = function(cb) { }); }; -module.exports = POP3Client; \ No newline at end of file +module.exports = POP3Client;