dongzhuoxie1244 2016-03-23 07:28
浏览 77

ZeroMQ:路由器经销商,路由器未接收数据

I am new to zeroMQ and am trying to create a server (with router socket bound to a local port) and a client with a dealer socket which connects to the router socket on the local port. The client sends data and exits, however nothing shows up on the router socket i.e. the Recv(0) call blocks forever. The server and client codes are as follows:

zmserver.go:

package main

import ("fmt"
         zmq "github.com/pebbe/zmq4")

func main() {

fmt.Println("Starting server")
serversock, _  := zmq.NewSocket(zmq.ROUTER)
serversock.Bind("tcp://*:5050")

identity, _ := serversock.Recv(0)
fmt.Println(identity) //nothing is printed
fmt.Println(serversock.Recv(0)) //nothing is printed
fmt.Println(serversock.Recv(0)) //nothing is printed
}

zmclient.go:

package main

import ("fmt"
         zmq "github.com/pebbe/zmq4")

func main(){

fmt.Println("Starting client")

clientsock, _ := zmq.NewSocket(zmq.DEALER)
defer clientsock.Close()
clientsock.SetIdentity("ID1")
clientsock.Connect("tcp://localhost:5050")  
clientsock.Send("", zmq.SNDMORE)
clientsock.Send("Hi Boss", 0)
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计