#include "zmq.h"
#include "zmq_utils.h" //Zeromq 函数的导入在这里帮我们实现了
#include <iostream>
#include <time.h>
#include <WinSock2.h>
#include <windows.h>
#include "../ZMQSimpleInclude/SimpleDef.h"
#pragma comment(lib,"libzmq-v100-mt-gd-4_0_4.lib")
int main()
{
// Prepare our context and socket
void *context = zmq_init (1);
void *receiver = zmq_socket (context, ZMQ_PULL);
zmq_bind (receiver, "tcp://*:5558");
// Wait for start of batch
char *string = s_recv (receiver);
free (string);
// Start our clock now
struct timeval tstart;
gettimeofday (&tstart, NULL);
// Process 100 confirmations
int task_nbr;
int total_msec = 0; // Total calculated cost in msecs
for (task_nbr = 0; task_nbr < 100; task_nbr++) {
char *string = s_recv (receiver);
free (string);
if ((task_nbr / 10) * 10 == task_nbr)
printf (":");
else
printf (".");
fflush (stdout);
}
// Calculate and report duration of batch
struct timeval tend, tdiff;
gettimeofday (&tend, NULL);
if (tend.tv_usec < tstart.tv_usec) {
tdiff.tv_sec = tend.tv_sec - tstart.tv_sec - 1;
tdiff.tv_usec = 1000000 + tend.tv_usec - tstart.tv_usec;
}
else {
tdiff.tv_sec = tend.tv_sec - tstart.tv_sec;
tdiff.tv_usec = tend.tv_usec - tstart.tv_usec;
}
total_msec = tdiff.tv_sec * 1000 + tdiff.tv_usec / 1000;
printf ("Total elapsed time: %d msec\n", total_msec);
zmq_close (receiver);
zmq_term (context);
return 0;
};
没有合适的资源?快使用搜索试试~ 我知道了~
ZMQ 三种模式实例
共228个文件
tlog:103个
log:17个
lastbuildstate:13个
5星 · 超过95%的资源 需积分: 43 148 下载量 127 浏览量
2017-04-03
19:38:56
上传
评论 4
收藏 11.52MB ZIP 举报
温馨提示
ZeroMQ-Guide(中文版)中的代码实现版,使用VC2010,ZMQ4.0.4版本,X64环境下编译。只编译有debug。需要自己安装ZMQ4.0.4的版本;本地编译需要重新修改下include和lib文件夹的指向。x64/debug文件夹中的exe可直接运行。
资源推荐
资源详情
资源评论
收起资源包目录
ZMQ 三种模式实例 (228个子文件)
ZMQClientSimple.vcxprojResolveAssemblyReference.cache 713B
ZMQSimpleSubscribe.vcxprojResolveAssemblyReference.cache 713B
ZMQSimplePULL.vcxprojResolveAssemblyReference.cache 713B
PullMain.cpp 1KB
ClientMain.cpp 1KB
ServerMain.cpp 1KB
SubscribeMain.cpp 1KB
PusMain.cpp 1KB
WorkMain.cpp 1KB
PublishMain.cpp 1KB
libzmq-v100-mt-gd-4_0_4.dll 1.82MB
libzmq-v100-mt-4_0_4.dll 539KB
ZMQClientSimpled.exe 66KB
ZMQClientSimpledd.exe 65KB
ZMQSimpleServerd.exe 40KB
ZMQSimplePULL.exe 37KB
ZMQSimpleSubscribed.exe 37KB
ZMQSimpleVentilatorPusd.exe 37KB
WorkerMain.exe 37KB
ZMQSimplePublish.exe 36KB
ZMQSimpleSubscribe.vcxproj.filters 951B
ZMQSimplePublish.vcxproj.filters 949B
ZMQClientSimple.vcxproj.filters 948B
ZMQSimpleServer.vcxproj.filters 948B
WorkerMain.vcxproj.filters 946B
ZMQSimplePULL.vcxproj.filters 946B
ZMQSimpleVentilatorPus.vcxproj.filters 945B
ZMQSimpleDemo.vcxproj.filters 823B
SimpleDef.h 4KB
vc100.idb 563KB
vc100.idb 547KB
vc100.idb 547KB
vc100.idb 547KB
vc100.idb 547KB
vc100.idb 539KB
vc100.idb 539KB
vc100.idb 531KB
vc100.idb 523KB
vc100.idb 523KB
ZMQSimpleSubscribe.lastbuildstate 66B
ZMQClientSimple.lastbuildstate 64B
ZMQSimpleSubscribe.lastbuildstate 64B
ZMQSimpleServer.lastbuildstate 64B
ZMQSimpleDemo.lastbuildstate 64B
ZMQSimpleVentilatorPus.lastbuildstate 62B
ZMQClientSimple.lastbuildstate 62B
WorkerMain.lastbuildstate 62B
ZMQSimplePublish.lastbuildstate 62B
ZMQSimpleSubscribe.lastbuildstate 62B
ZMQSimpleServer.lastbuildstate 62B
ZMQSimplePULL.lastbuildstate 62B
ZMQSimpleDemo.lastbuildstate 62B
ZMQSimpleSubscribe.log 5KB
ZMQSimpleVentilatorPus.log 5KB
ZMQSimpleSubscribe.log 5KB
ZMQSimplePublish.log 4KB
ZMQSimpleSubscribe.log 4KB
ZMQSimplePULL.log 3KB
WorkerMain.log 3KB
ZMQSimpleServer.log 3KB
ZMQClientSimple.log 3KB
ZMQSimpleServer.log 3KB
ZMQClientSimple.log 2KB
ZMQSimplePublish.Build.CppClean.log 1KB
ZMQSimpleServer.Build.CppClean.log 1KB
ZMQSimpleSubscribe.Build.CppClean.log 1KB
ZMQSimpleDemo.log 803B
ZMQSimpleDemo.log 681B
ZMQSimpleDemo.Build.CppClean.log 195B
ZMQSimpleVentilatorPus.exe.intermediate.manifest 381B
ZMQClientSimple.exe.intermediate.manifest 381B
ZMQClientSimpled.exe.intermediate.manifest 381B
ZMQClientSimple.exe.intermediate.manifest 381B
WorkerMain.exe.intermediate.manifest 381B
ZMQSimplePublish.exe.intermediate.manifest 381B
ZMQSimpleSubscribe.exe.intermediate.manifest 381B
ZMQSimpleSubscribe.exe.intermediate.manifest 381B
ZMQSimpleServer.exe.intermediate.manifest 381B
ZMQSimpleServer.exe.intermediate.manifest 381B
ZMQSimplePULL.exe.intermediate.manifest 381B
SubscribeMain.obj 688KB
ClientMain.obj 140KB
ServerMain.obj 66KB
ClientMain.obj 66KB
ServerMain.obj 66KB
PusMain.obj 52KB
WorkMain.obj 52KB
PublishMain.obj 51KB
SubscribeMain.obj 51KB
SubscribeMain.obj 51KB
PullMain.obj 51KB
vc100.pdb 284KB
vc100.pdb 284KB
vc100.pdb 284KB
vc100.pdb 284KB
vc100.pdb 284KB
vc100.pdb 284KB
vc100.pdb 284KB
vc100.pdb 276KB
vc100.pdb 276KB
共 228 条
- 1
- 2
- 3
资源评论
- zhangkui_2232019-11-14不错,很实用
- windsnow832019-04-23可以参考一下
- cnds代号2017-09-18还可以,可以参考一下
- qq_148126032019-08-18还没来得及看呢
bushionmath
- 粉丝: 20
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功