/* Send msg to server and return the result msg */
string GerenciadorServidores::sendServer(string msg,int port){
   boost::asio::io_service io_service;

   tcp::socket s(io_service);
   tcp::resolver resolver(io_service);
   boost::asio::connect(s, resolver.resolve({"127.0.0.1",
            to_string(port).c_str()}));

   size_t request_length = std::strlen(msg.c_str());
   boost::asio::write(s, boost::asio::buffer(msg.c_str(),
            request_length));

   char reply[10000];
   size_t reply_length = boost::asio::read(s,
         boost::asio::buffer(reply, request_length));

   message_ptr msg_ptr = messageParse(string(reply));
   return string(reply);
}
Пример #2
0
void Server::execMsg(string msg){
	message_ptr message = messageParse(msg);
	string res = interpretarMsg(message->reason,message->atributes);
	write_to_pipe(res);
}