繁体   English   中英

'net'拒绝在nodejs中发出'close'事件

[英]'net' refuses to emit 'close' event in nodejs

嗨,我有以下代码:

this.stop = function() {
    this.server.close();
    var thisServer = this;
    this.server.on('close',function() {
        thisServer.emit('stop');        
    });     
};

使用服务器并调用stop函数后,服务器拒绝发出“关闭”事件,并且

    this.server.on('close',function() {
        thisServer.emit('stop');        
    }); 

难道我做错了什么?

this.server.on('close',function() {
    thisServer.emit('stop');        
});    
this.server.close();
var thisServer = this;

在调用close之前绑定close事件。

或者尝试this.server.destroy();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM