当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Socket.destroy方法代码示例

本文整理汇总了TypeScript中net.Socket.destroy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Socket.destroy方法的具体用法?TypeScript Socket.destroy怎么用?TypeScript Socket.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.Socket的用法示例。


在下文中一共展示了Socket.destroy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: disconnect

    /**
     * disconnect the TCP layer and close the underlying socket.
     * The ```"close"``` event will be emitted to the observers with err=null.
     *
     * @method disconnect
     * @async
     * @param callback
     */
    public disconnect(callback: ErrorCallback): void {

        assert(_.isFunction(callback), "expecting a callback function, but got " + callback);

        if (this._disconnecting) {
            callback();
            return;
        }

        assert(!this._disconnecting, "TCP Transport has already been disconnected");
        this._disconnecting = true;

        // xx assert(!this._theCallback,
        //              "disconnect shall not be called while the 'one time message receiver' is in operation");
        this._cleanup_timers();

        if (this._socket) {
            this._socket.end();
            this._socket.destroy();
            // xx this._socket.removeAllListeners();
            this._socket = null;
        }
        setImmediate(() => {
            this.on_socket_ended(null);
            callback();
        });
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:35,代码来源:tcp_transport.ts

示例2: _cleanUpProcess

 private _cleanUpProcess(): void {
   this._inSocket.readable = false;
   this._inSocket.writable = false;
   this._outSocket.readable = false;
   this._outSocket.writable = false;
   this._outSocket.destroy();
 }
开发者ID:sedwards2009,项目名称:extraterm,代码行数:7,代码来源:windowsPtyAgent.ts

示例3: resolve

        client.on('data', () => {
          /**
           * Promise Resolve
           */
          resolve(true)

          client.destroy() // kill client after server's response
        })
开发者ID:KiddoLin,项目名称:wechaty,代码行数:8,代码来源:doctor.ts

示例4: dispose

 public dispose() {
     assert(!this._timerId);
     if (this._socket) {
         this._socket.destroy();
         this._socket.removeAllListeners();
         this._socket = null;
     }
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:8,代码来源:tcp_transport.ts

示例5: function

 process.on('exit', function () {
   try {
     log.info('Terminating socket...');
     sock.end();
     sock.destroy();
   } catch (ex) {
     //nop
   }
 });
开发者ID:jffry,项目名称:rocket-r60v,代码行数:9,代码来源:measure.ts

示例6: debugLog

 this._socket.setTimeout(this.timeout, () => {
     debugLog(` _socket ${this.name} has timed out (timeout = ${this.timeout})`);
     if (this._socket) {
         this._socket.destroy();
         // 08/2008 shall we do this ?
         this._socket.removeAllListeners();
         this._socket = null;
     }
 });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:9,代码来源:tcp_transport.ts

示例7: dispose

    public dispose(): void
    {
        this.m_bufferLength = 0;
        this.m_buffer = null;
        
        if (this.m_fd != null)
        {
            this.m_fd.destroy();
            this.m_fd = null;
        }

        super.dispose();
    }
开发者ID:Kelmar,项目名称:LunaIRC,代码行数:13,代码来源:tcpTransport.ts

示例8: clearTimeout

 return new Promise<void>((resolve) => {
   if (this.timeout) {
     clearTimeout(this.timeout);
     this.timeout = null;
   }
   if (this.connectingSubscription) {
     this.connectingSubscription.unsubscribe();
     this.connectingSubscription = null;
   }
   this.socket.removeAllListeners();
   this.socket.once("close", () => resolve());
   this.socket.destroy();
   this.socket = null;
 });
开发者ID:svi3c,项目名称:rx-messaging,代码行数:14,代码来源:ClientConnector.ts

示例9: _on_socket_close

    private _on_socket_close(hadError: boolean) {
        // istanbul ignore next
        if (doDebug) {
            debugLog(chalk.red(" SOCKET CLOSE : "),
              chalk.yellow("had_error ="), chalk.cyan(hadError.toString()), this.name);
        }
        if (this._socket) {
            debugLog("  remote address = ",
              this._socket.remoteAddress, " ", this._socket.remoteFamily, " ", this._socket.remotePort);
        }
        if (hadError) {
            if (this._socket) {
                this._socket.destroy();
            }
        }
        const err = hadError ? new Error("ERROR IN SOCKET") : undefined;
        this.on_socket_closed(err);

    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:tcp_transport.ts

示例10: if

    _socket = _socket.prependOnceListener("lookup", (err, address, family, host) => {
        error = err;

        if (typeof family === 'string') {
            str = family;
        } else if (typeof family === 'number') {
            num = family;
        }

        str = host;
    });
    _socket = _socket.prependOnceListener("timeout", () => { });

    bool = _socket.connecting;
    bool = _socket.destroyed;
    _socket.destroy();
}

{
    /**
     * net.Server - events.EventEmitter
     *   1. close
     *   2. connection
     *   3. error
     *   4. listening
     */
    let _server = net.createServer();

    let _socket = net.connect('');
    let bool: boolean;
    let error = new Error();
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:net.ts


注:本文中的net.Socket.destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。