fast-tcp
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -13,6 +13,5 @@ 'use strict'; | ||
USE_QUEUE: true, | ||
QUEUE_SIZE: Infinity, | ||
TIMEOUT: 0 // Disabled by default | ||
QUEUE_SIZE: Infinity | ||
}; | ||
module.exports = Constants; |
@@ -148,3 +148,4 @@ 'use strict'; | ||
Sock.prototype.setKeepAlive = function (enable, initialDelay) { | ||
this._socketConfig.keepAlive = { enable: enable, initialDelay: initialDelay }; | ||
this._socketConfig.keepAliveEnable = enable; | ||
this._socketConfig.keepAliveInitialDelay = initialDelay; | ||
@@ -240,4 +241,4 @@ if (this._connected) { | ||
if (config.keepAlive !== undefined) { | ||
this.setKeepAlive(config.keepAlive.enable, config.keepAlive.initialDelay); | ||
if (config.keepAliveEnable !== undefined || config.keepAliveInitialDelay !== undefined) { | ||
this.setKeepAlive(config.keepAliveEnable, config.keepAliveInitialDelay); | ||
} | ||
@@ -302,8 +303,3 @@ }; | ||
this._socket.on('error', function (err) { | ||
/** | ||
* Error event from net.Socket. | ||
* | ||
* @event Sock#error | ||
*/ | ||
_this._superEmit('error', err); | ||
_this._onError(err); | ||
}); | ||
@@ -313,9 +309,3 @@ | ||
_this._socket.destroy(); | ||
/** | ||
* TIMEOUT error event. | ||
* | ||
* @event Sock#error | ||
*/ | ||
_this._superEmit('error', ut.error('connect TIMEOUT')); | ||
_this._onError(ut.error('connect TIMEOUT')); | ||
}); | ||
@@ -424,2 +414,16 @@ | ||
Sock.prototype._onError = function (err) { | ||
if (this.listenerCount('error') > 0) { | ||
/** | ||
* Error event from net.Socket. | ||
* | ||
* @event Sock#error | ||
*/ | ||
this._superEmit('error', err); | ||
} else { | ||
console.error('Missing error handler on `socket`.'); | ||
console.error(err.stack); | ||
} | ||
}; | ||
module.exports = Sock; |
{ | ||
"name": "fast-tcp", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "fast-tcp is an extremely fast TCP client and server that allows to emit and listen to events", | ||
@@ -5,0 +5,0 @@ "author": "Alejandro Santiago Nieto", |
@@ -55,7 +55,2 @@ fast-tcp | ||
}); | ||
// It's required, otherwise node.js will throw an "Unhandled 'error' event" | ||
socket.on('error', function (err) { | ||
console.error(err); | ||
}); | ||
``` | ||
@@ -62,0 +57,0 @@ |
45654
1165
213