//zeromp 通讯测试server 端
#include "zmq.h"
#include "zmq_utils.h" //Zeromq 函数的导入在这里帮我们实现了
#include <iostream>
#pragma comment(lib,"libzmq-v100-mt-gd-4_0_4.lib")
int main()
{
std::cout << "-------------------Zeromq REP style-----------------------" <<std::endl;
std::cout << "---------------------Author:SanYue------------------------" <<std::endl;
void* context=zmq_init(1); //指定zmq 处理I/0事件的thread pool 为1
void* z_socket=zmq_socket(context,ZMQ_REP);
zmq_bind(z_socket,"tcp://*:5555"); // accept connections on a socket
int recvn=1;
while(1) //循环工作
{
//接受部分
zmq_msg_t recv_msg;
zmq_msg_init(&recv_msg);
zmq_msg_recv(&recv_msg,z_socket,0); //0表示非阻塞
std::cout<<"第\t"<<recvn++<<"\t次收到client信息:\t";
std::cout<<(char*)zmq_msg_data(&recv_msg)<<std::endl;
zmq_msg_close(&recv_msg);
//发送部分
zmq_msg_t send_msg;
zmq_msg_init_size(&send_msg,6);
memcpy(zmq_msg_data(&send_msg),"world",6);
zmq_sendmsg(z_socket,&send_msg,0);
zmq_msg_close(&send_msg);
}
zmq_close(z_socket);
zmq_term(context);
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ZMQSimpleDemo.7z (89个子文件)
ZMQSimpleDemo
ZMQSimpleDemo.suo 17KB
ZMQSimpleDemo
Debug
ZMQSimpleDemo.Build.CppClean.log 195B
ZMQSimpleDemo.write.1.tlog 0B
ZMQSimpleDemo.log 681B
ZMQSimpleDemo.lastbuildstate 64B
ZMQSimpleDemo.vcxproj.user 143B
x64
Debug
ZMQSimpleDemo.write.1.tlog 0B
ZMQSimpleDemo.log 803B
ZMQSimpleDemo.lastbuildstate 62B
ZMQSimpleDemo.vcxproj 7KB
ZMQSimpleDemo.vcxproj.filters 823B
ZMQSimpleDemo.sdf 28.14MB
ZMQSimpleServer
ZMQSimpleServer.vcxproj 7KB
Debug
cl.command.1.tlog 806B
ZMQSimpleServer.write.1.tlog 0B
CL.read.1.tlog 22KB
vc100.idb 539KB
mt.read.1.tlog 794B
ZMQSimpleServer.unsuccessfulbuild 0B
link.read.1.tlog 2B
ZMQSimpleServer.exe.intermediate.manifest 381B
link.write.1.tlog 2B
ServerMain.obj 66KB
CL.write.1.tlog 432B
ZMQSimpleServer.lastbuildstate 64B
ZMQSimpleServer.log 3KB
vc100.pdb 284KB
link.command.1.tlog 2B
mt.write.1.tlog 336B
mt.command.1.tlog 528B
ServerMain.cpp 1KB
ZMQSimpleServer.vcxproj.filters 948B
ZMQSimpleServer.vcxproj.user 143B
x64
Debug
cl.command.1.tlog 792B
ZMQSimpleServer.write.1.tlog 0B
CL.read.1.tlog 22KB
vc100.idb 523KB
mt.read.1.tlog 812B
link.read.1.tlog 3KB
ZMQSimpleServer.exe.intermediate.manifest 381B
link.write.1.tlog 786B
ServerMain.obj 66KB
CL.write.1.tlog 448B
ZMQSimpleServer.lastbuildstate 62B
ZMQSimpleServer.log 3KB
vc100.pdb 276KB
link.command.1.tlog 2KB
mt.write.1.tlog 354B
ZMQSimpleServer.Build.CppClean.log 1KB
mt.command.1.tlog 554B
x64
Debug
ZMQSimpleServerd.exe 40KB
ZMQClientSimpled.exe 65KB
libzmq-v100-mt-4_0_4.dll 539KB
libzmq-v100-mt-gd-4_0_4.dll 1.82MB
ZMQClientSimple
Debug
cl.command.1.tlog 806B
ClientMain.obj 66KB
CL.read.1.tlog 22KB
vc100.idb 523KB
link.read.1.tlog 2B
link.write.1.tlog 2B
ZMQClientSimple.write.1.tlog 0B
CL.write.1.tlog 432B
vc100.pdb 276KB
link.command.1.tlog 2B
ZMQClientSimple.log 3KB
ZMQClientSimple.exe.intermediate.manifest 381B
ZMQClientSimple.lastbuildstate 64B
ZMQClientSimple.unsuccessfulbuild 0B
ZMQClientSimple.vcxproj 7KB
x64
Debug
cl.command.1.tlog 792B
ClientMain.obj 136KB
CL.read.1.tlog 22KB
vc100.idb 547KB
mt.read.1.tlog 812B
link.read.1.tlog 3KB
link.write.1.tlog 786B
ZMQClientSimple.write.1.tlog 0B
CL.write.1.tlog 448B
vc100.pdb 284KB
link.command.1.tlog 2KB
mt.write.1.tlog 490B
ZMQClientSimple.log 3KB
ZMQClientSimple.exe.intermediate.manifest 381B
ZMQClientSimple.lastbuildstate 62B
mt.command.1.tlog 554B
ZMQClientSimple.vcxproj.filters 948B
ClientMain.cpp 1KB
ZMQClientSimple.vcxproj.user 143B
ZMQSimpleDemo.sln 3KB
共 89 条
- 1
资源评论
bushionmath
- 粉丝: 20
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功