热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

wantdevice/rendezvousserverdemo

https://github.com/nanomsg/nanomsg/issues/271https://github.com/nanomsg/nanomsg/issu

https://github.com/nanomsg/nanomsg/issues/271
https://github.com/nanomsg/nanomsg/issues/399
http://250bpm.com/blog:14
http://nanomsg.freelists.narkive.com/7os9qW2V/a-stupid-load-balancing-question
Just use REQs, REPs and a device in the middle. When creating sockets
for the device, use AF_SP_RAW family (AF_SP_RAW+REQ is what's called
DEALER in ZeroMQ parlance, and AF_SO_RAW+REP corresponds to ROUTER).

from above urls ,it seems that with nn_device , multiple client can connnect multiple server
from nn_device description, nn_device only connect two sockets:

http://nanomsg.org/v1.0.0/nn_device.3.html
EXAMPLE
int s1 = nn_socket (AF_SP_RAW, NN_REQ);
nn_bind (s1, "tcp://127.0.0.1:5555");
int s2 = nn_socket (AF_SP_RAW, NN_REP);
nn_bind (s2, "tcp://127.0.0.1:5556");
nn_device (s1, s2);

I want to distribute the load on server side.
the topology is as following:

1
2
3
4
5
6
7
8
9
        |----------------|

        |                |

req1----|                |-----rep1

req2----|nn_device(s1,s2)|-----rep2

req3----|                |-----rep3

        |                |

        |                |

        |                |

        |----------------|

are the following pseudocodes correct?
step 1: create nn_device
int s1 = nn_socket (AF_SP_RAW, NN_REQ);
nn_bind (s1, "tcp://127.0.0.1:5555");
int s2 = nn_socket (AF_SP_RAW, NN_REP);
nn_bind (s2, "tcp://127.0.0.1:5556");
nn_device (s1, s2);
step 2 :create multi servers(rep)
int rep1 = nn_socket (AF_SP, NN_REP);
int rep2 = nn_socket (AF_SP, NN_REP);
int rep3 = nn_socket (AF_SP, NN_REP);
nn_connect (rep1, "tcp://127.0.0.1:5555");
nn_connect (rep2, "tcp://127.0.0.1:5555");
nn_connect (rep2, "tcp://127.0.0.1:5555");
step 3:create mutli client (req)
int req1 = nn_socket (AF_SP, NN_REQ);
int req2 = nn_socket (AF_SP, NN_REQ);
int req3 = nn_socket (AF_SP, NN_REQ);
nn_connect (req1, "tcp://127.0.0.1:5556");
nn_connect (req2, "tcp://127.0.0.1:5556");
nn_connect (req2, "tcp://127.0.0.1:5556");

thanks a lot

该提问来源于开源项目:nanomsg/nanomsg

Hmm.. it seems I was wrong about about device — it blocks forever as long
as the sockets are open. (Just checked the code, and have removed the
pause() from my demo.

Looking again at your code, I just realized something… your IP addresses do
not match!

The IP address you use use for the bind side is the local IP address on
the server. You can even omit it to listen on all interfaces - e.g.
tcp://:5556 will cause the server to listen on every network interface on
TCP port 5556.

The IP address you use for connect is the remote IP address.

I’m about 95% certain that this is the problem.

On Wed, Nov 23, 2016 at 12:10 AM, kuncao notifications.com wrote:

your device is exiting main. you need to pause there without exiting.
pause() is a good unix function for this.

I add pause in my c++ code,but it seem to I have to use control +c twice
to shutdown device,without pause(),only once control +c to shutown the
device.
-------------------with pause()test begin --------------------------------
szv1000082629:/home/nanoprorpc/nanorpc # ./device_server
s1 value is : 0
s2 value is : 1
^CExiting on ^C control c
after nn_device init : -1

afdadf
adfsasdf
wd
ddd
^CExiting on ^C control c
-------------------with pause() test end--------------------------------
afdadf and other letters is to verify the device can be shutdown after
pause()

-------------------without pause() test begin-------------------------
-------szv1000082629:/home/nanoprorpc/nanorpc # ./device_server
s1 value is : 0
s2 value is : 1
^CExiting on ^C control c
after nn_device init : -1

-------------------without pause() test end---------------------------

my code:

include
include
include
include
include
include

void OnExit(int sig)
{
nn_term();//this is added by jackcao at 20161123
// to term the socket s1 s2
//and may term other socket created by nanomsg in this server
std::cerr <<"Exiting on ^C " <<"control c" <}

int main(int argc, char *argv[])
{
signal(SIGINT, OnExit);
int s1 = nn_socket (AF_SP_RAW, NN_REP);
std::cerr <<"s1 value is : " <nn_bind (s1, "tcp://10.120.229.120:5555");
int s2 = nn_socket (AF_SP_RAW, NN_REQ);
std::cerr <<"s2 value is : " <nn_bind (s2, "tcp://10.120.229.120:5556");
int sd=nn_device (s1, s2);

std::cerr <<"after nn_device init : " <//pause();
return 0;
}


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/nanomsg/nanomsg/issues/832#issuecomment-262453754,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPDfYB4aXuW2zkuXlhXYuRlOPX3lZr9ks5rA_ThgaJpZM4K33Zp
.


推荐阅读
  • 解决Jenkins编译过程中ERROR: Failed to Parse POMs的问题
    在使用Jenkins进行自动化构建时,有时会遇到“ERROR: Failed to parse POMs”的错误。本文将详细分析该问题的原因,并提供有效的解决方案。 ... [详细]
  • 可参照github代码:https:github.comrabbitmqrabbitmq-tutorialsblobmasterjavaEmitLogTopic.ja ... [详细]
  • iOS snow animation
    CTSnowAnimationView.hCTMyCtripCreatedbyalexon1614.Copyright©2016年ctrip.Allrightsreserved.# ... [详细]
  • 本文介绍了 Go 语言中的高性能、可扩展、轻量级 Web 框架 Echo。Echo 框架简单易用,仅需几行代码即可启动一个高性能 HTTP 服务。 ... [详细]
  • 命令模式是一种行为设计模式,它将请求封装成一个独立的对象,从而允许你参数化不同的请求、队列请求或者记录请求日志。本文将详细介绍命令模式的基本概念、组件及其在实际场景中的应用。 ... [详细]
  • Java Socket 关键参数详解与优化建议
    Java Socket 的 API 虽然被广泛使用,但其关键参数的用途却鲜为人知。本文详细解析了 Java Socket 中的重要参数,如 backlog 参数,它用于控制服务器等待连接请求的队列长度。此外,还探讨了其他参数如 SO_TIMEOUT、SO_REUSEADDR 等的配置方法及其对性能的影响,并提供了优化建议,帮助开发者提升网络通信的稳定性和效率。 ... [详细]
  • 在Cisco IOS XR系统中,存在提供服务的服务器和使用这些服务的客户端。本文深入探讨了进程与线程状态转换机制,分析了其在系统性能优化中的关键作用,并提出了改进措施,以提高系统的响应速度和资源利用率。通过详细研究状态转换的各个环节,本文为开发人员和系统管理员提供了实用的指导,旨在提升整体系统效率和稳定性。 ... [详细]
  • centos 7.0 lnmp成功安装过程(很乱)
    下载nginx[rootlocalhostsrc]#wgethttp:nginx.orgdownloadnginx-1.7.9.tar.gz--2015-01-2412:55:2 ... [详细]
  • 【线段树】  本质是二叉树,每个节点表示一个区间[L,R],设m(R-L+1)2(该处结果向下取整)左孩子区间为[L,m],右孩子区间为[m ... [详细]
  • 本文将介绍如何在混合开发(Hybrid)应用中实现Native与HTML5的交互,包括基本概念、学习目标以及具体的实现步骤。 ... [详细]
  • 2020年9月15日,Oracle正式发布了最新的JDK 15版本。本次更新带来了许多新特性,包括隐藏类、EdDSA签名算法、模式匹配、记录类、封闭类和文本块等。 ... [详细]
  • 基于iSCSI的SQL Server 2012群集测试(一)SQL群集安装
    一、测试需求介绍与准备公司计划服务器迁移过程计划同时上线SQLServer2012,引入SQLServer2012群集提高高可用性,需要对SQLServ ... [详细]
  • 文章目录Golang定时器Timer和Tickertime.Timertime.NewTimer()实例time.AfterFunctime.Tickertime.NewTicke ... [详细]
  • 本文介绍了如何使用Python的Paramiko库批量更新多台服务器的登录密码。通过示例代码展示了具体实现方法,确保了操作的高效性和安全性。Paramiko库提供了强大的SSH2协议支持,使得远程服务器管理变得更加便捷。此外,文章还详细说明了代码的各个部分,帮助读者更好地理解和应用这一技术。 ... [详细]
  • 在使用Eclipse进行调试时,如果遇到未解析的断点(unresolved breakpoint)并显示“未加载符号表,请使用‘file’命令加载目标文件以进行调试”的错误提示,这通常是因为调试器未能正确加载符号表。解决此问题的方法是通过GDB的`file`命令手动加载目标文件,以便调试器能够识别和解析断点。具体操作为在GDB命令行中输入 `(gdb) file `。这一步骤确保了调试环境能够正确访问和解析程序中的符号信息,从而实现有效的调试。 ... [详细]
author-avatar
江苏经贸学院
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有