diff --git a/lib/smpp.js b/lib/smpp.js index 3bf3e9d..392a303 100644 --- a/lib/smpp.js +++ b/lib/smpp.js @@ -16,16 +16,13 @@ function Session(options) { } else { this.port = options.port; this.host = options.host; - this.socket = net.createConnection(this.port, this.host); + this.socket = net.connect(this.port, this.host); this.socket.on('connect', function() { self.emit('connect'); }); } this.socket.on('data', function(chunk) { - var oldBuffer = self._buffer; - self._buffer = new Buffer(oldBuffer.length + chunk.length); - oldBuffer.copy(self._buffer); - chunk.copy(self._buffer, oldBuffer.length); + self._buffer = Buffer.concat([self._buffer, chunk]); self._extractPDUs(); }); this.socket.on('close', function() {