If one object has connect() called more than once (like when reconnecting),
make sure we destroy the previous socket rather than leaking it.
* @param {Object} createInfo The socket details
*/
TcpClient.prototype._onCreate = function(createInfo) {
+ if (this.socketId !== null) {
+ socket.destroy(this.socketId);
+ }
this.socketId = createInfo.socketId;
if (this.socketId > 0) {
socket.connect(this.socketId, this.host, this.port, this._onConnectComplete.bind(this));