fixed protocol version

This commit is contained in:
brianc 2010-10-23 13:28:14 -05:00
parent dea4424e97
commit bdb4d28038

View File

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