-
-
Save jameshilliard/385de9d6b029dacd72a8248ecbdcd5c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function send(cmd) { | |
net = require('net') | |
var self = this | |
var fp = "/opt/ninjadb/listener" | |
var send_sep = '.'; | |
var fld_sep = String.fromCharCode(9); | |
var val_sep = "="; | |
var msg = cmd; | |
console.log('send', cmd); | |
msg = msg | |
var sock = net.connect(fp, function(err) { | |
if (err) { | |
console.log('ckdb connection error'); | |
return err | |
} | |
sock.setKeepAlive(true) | |
// write the length | |
var len = msg.length | |
var l = new Buffer(4) | |
l.writeUInt32LE(len) | |
sock.write(l) | |
// then write the actual message | |
var buf = new Buffer(msg) | |
sock.write(buf) | |
}) | |
sock.on('error', function(err) { | |
console.log('socket error'); | |
return err | |
}) | |
sock.on('data', function(chunk) { | |
var len = chunk.readUInt32LE(0) | |
var out = chunk.slice(4, chunk.length) | |
console.log("response: " + out.toString()); | |
return out | |
}) | |
} | |
console.log(send("setopts.1.oc_BlocksPageSize.value=1000\n")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment