123456789101112131415161718192021222324252627282930313233 |
- //
- // Created by zx on 2019/12/17.
- //
- #include "MeasureRequest.h"
- #include <nnxx/message.h>
- #include <nnxx/message_control.h>
- #include <nnxx/socket.h>
- #include <nnxx/reqrep.h>
- #include <nnxx/timeout.h>
- #include <nnxx/error.h>
- MeasureRequest::MeasureRequest(std::string connectStr)
- {
- m_connect_str=connectStr;
- }
- bool MeasureRequest::Request(std::string cmd,std::string& response)
- {
- nnxx::socket sock{ nnxx::SP, nnxx::REQ };
- sock.connect(m_connect_str);
- sock.send(cmd);
- nnxx::message message;
- try { nnxx::with_recv_timeout _ { sock, std::chrono::milliseconds(1000) };
- message=sock.recv();
- }
- catch (const nnxx::timeout_error &) {
- return false;
- }
- catch (const std::exception &) {
- return false;
- }
- response=nnxx::to_string(message);
- return true;
- }
|