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); });