From bdb4d280380922277e77b416f1ec501e437bba78 Mon Sep 17 00:00:00 2001 From: brianc Date: Sat, 23 Oct 2010 13:28:14 -0500 Subject: [PATCH] fixed protocol version --- lib/client.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index d5f8e070..95cd9dd4 100644 --- a/lib/client.js +++ b/lib/client.js @@ -35,10 +35,13 @@ p.connect = function() { var self = this; this.stream.on('connect', function() { var data = ['user',self.user,'database', self.database, '\0'].join('\0'); - var dataBuffer = Buffer(data, self.encoding); - var fullBuffer = Buffer(4 + dataBuffer.length); - self.writeInt32(fullBuffer, 0, 0x03);//write protocol version - dataBuffer.copy(fullBuffer, 4, 0); + var byteLength = Buffer.byteLength(data); + var fullBuffer = new Buffer(byteLength + 4); + fullBuffer[0] = 0; + fullBuffer[1] = 3; + fullBuffer[2] = 0; + fullBuffer[3] = 0; + fullBuffer.write(data, 4); self.send(null, fullBuffer); });