我是靠谱客的博主 典雅服饰,这篇文章主要介绍 学习代码 Request-reply client in C++,现在分享给大家,希望可以做个参考。

//Request-reply client in C++
//Connects REQ socket to tcp://localhost:5559
//Sends "Hello" to server, expects "World" back
//
// Olivier Chamoux <olivier.chamoux@fr.thalesgroup.com>

#include "zhelpers.hpp"

int main (int argc,char *argv[])
{
           zmq::context_t context(1);

           zmq::socket_t requester(context, ZMQ_REQ);
           requester.connect("tcp://localhost:5559");

           for(int request =0 ; request <10 ; request++) {

                  s_send (requester, "Hello");
                  std::string string= s_recv (requester);

                  std::cout<< "Received reply " << request<<" ["<< string<< "]" << std::endl;
      }

         return 0;
}

最后

以上就是典雅服饰最近收集整理的关于 学习代码 Request-reply client in C++的全部内容,更多相关内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部