Assuming the following code C++ snippet:
...
zmq::context_t context(1);
zmq::socket_t server(context, ZMQ_REP);
server.bind(std::string("tcp://*:"+args.port).c_str());
zmq::message_t request;
server.recv(&request);
qry_request* req = (qry_request*) request.data();
...
...
struct qry_request {
uint8_t type;
uint8_t mode;
uint8_t phrases;
double phrase_threshold;
uint64_t id;
uint64_t k;
uint8_t output_results;
uint8_t int_qry;
char qry_str[MAX_QRY_LEN] = {0};
};
Now, I want to connect with the server using zero mq on Node.js, so I coded the following program:
...
socket.connect('tcp://127.0.0.1:12345');
var req = {};
req['type'] = 0;
req.mode = 1;
req.int_qry = 0;
req.phrases = 0;
req.phrase_threshold = 0.0;
req.output_results = 1
req['id'] = 123;
req.k = 10;
req.qry_str = ['a'];
socket.send(JSON.stringify(req));
Unfortunately, I am receiving the following error on the server side.
libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: stoull: no conversion
Abort trap: 6
Most likely, there is a problem with the encoding of the sender's message. I tried it with socket.send(req); but that doesn't work either.
Aucun commentaire:
Enregistrer un commentaire