Skip to content

Commit

Permalink
Fix issue since node 0.10.0 (readable streams) that caused premature …
Browse files Browse the repository at this point in the history
…socket end after first chunk. Fixes mattcg/socks5-http-client/issues/1.
  • Loading branch information
mattcg committed Apr 23, 2013
1 parent 19f221b commit 8a70fa1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/socket.js
Expand Up @@ -21,7 +21,7 @@
/*jshint node:true*/

var net = require('net');
var stream = require('stream');
var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;

var htons = require('network-byte-order').htons;
Expand All @@ -40,7 +40,7 @@ exports.createConnection = function(options) {
function Socks5ClientSocket(socksHost, socksPort) {
var self = this;

stream.Stream.call(self);
EventEmitter.call(self);

self.socket = new net.Socket();
self.socksHost = socksHost;
Expand All @@ -57,8 +57,7 @@ function Socks5ClientSocket(socksHost, socksPort) {
});
}

//inherits(Socks5ClientSocket, net.Socket);
inherits(Socks5ClientSocket, stream.Stream);
inherits(Socks5ClientSocket, EventEmitter);

Socks5ClientSocket.prototype.setTimeout = function(msecs, callback) {
return this.socket.setTimeout(msecs, callback);
Expand Down Expand Up @@ -121,10 +120,6 @@ Socks5ClientSocket.prototype.connect = function(port, host) {
Socks5ClientSocket.prototype.handleSocksConnectToHost = function() {
var self = this;

self.socket.on('data', function(data) {
self.emit('data', data);
});

self.socket.on('close', function(hadError) {
self.emit('close', hadError);
});
Expand All @@ -137,6 +132,7 @@ Socks5ClientSocket.prototype.handleSocksConnectToHost = function() {
self.socket.parser = self.parser;
self.socket.ondata = self.ondata;
self.writable = true;
self.readable = true;
self.emit('connect');
};

Expand Down

0 comments on commit 8a70fa1

Please sign in to comment.