Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add socket debug() instrumentation

  • Loading branch information...
commit b7f8a606d47db5878eea474569e0cf92515c0109 1 parent 25629a2
@tj authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/sockets/sock.js
View
7 lib/sockets/sock.js
@@ -4,7 +4,8 @@
*/
var net = require('net')
- , Emitter = require('events').EventEmitter;
+ , Emitter = require('events').EventEmitter
+ , debug = require('debug')('ss:sock');
/**
* Expose `Socket`.
@@ -43,6 +44,7 @@ function Socket() {
self.connected = false;
if (self.closing) return self.emit('close');
setTimeout(function(){
+ debug('attempting reconnect');
self.emit('reconnect attempt');
sock.destroy();
self.connect(self.port);
@@ -51,6 +53,7 @@ function Socket() {
});
sock.on('connect', function(){
+ debug('connect');
self.connected = true;
self.retry = self.retryTimeout;
self.emit('connect');
@@ -75,6 +78,7 @@ Socket.prototype.__proto__ = Emitter.prototype;
*/
Socket.prototype.connect = function(port, fn){
+ debug('connect %s', port);
this.type = 'client';
this.port = port;
this.sock.connect(port, '127.0.0.1');
@@ -89,6 +93,7 @@ Socket.prototype.connect = function(port, fn){
*/
Socket.prototype.close = function(){
+ debug('close');
this.closing = true;
this.sock.destroy();
return this;
Please sign in to comment.
Something went wrong with that request. Please try again.