本文整理汇总了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();
});
}
示例2: _cleanUpProcess
private _cleanUpProcess(): void {
this._inSocket.readable = false;
this._inSocket.writable = false;
this._outSocket.readable = false;
this._outSocket.writable = false;
this._outSocket.destroy();
}
示例3: resolve
client.on('data', () => {
/**
* Promise Resolve
*/
resolve(true)
client.destroy() // kill client after server's response
})
示例4: dispose
public dispose() {
assert(!this._timerId);
if (this._socket) {
this._socket.destroy();
this._socket.removeAllListeners();
this._socket = null;
}
}
示例5: function
process.on('exit', function () {
try {
log.info('Terminating socket...');
sock.end();
sock.destroy();
} catch (ex) {
//nop
}
});
示例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;
}
});
示例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();
}
示例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;
});
示例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);
}
示例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();