dta25920
2016-03-10 14:00
浏览 171
已采纳

用不同语言编写的ZeroMQ套接字的兼容性

I've built an app written on python, based on ZeroMQ, but now I'm facing perfomance issues. So I decided to rewrite some modules of my app using, let's say, Golang. But when I try to establish messaging between sockets, implemented by different languages, anything does not work.

I've searched so far, but I didn't find any info about compatibility problems of ZeroMQ using different languages.

So the question is: Can I use golang for server implementation based on ZeroMQ and client written on python to connect to it?
Or do I have to use only one language?

EDIT: here are typical server and client that I'm trying to get working properly

server:

import zmqctx = zmq.Context()
sock = ctx.socket(zmq.REP)
sock.bind("tcp://*:57000")
msg = sock.recv()

client:

package main

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

func main() {

    ctx, _ := zmq.NewContext()
    sock, _ := ctx.NewSocket(zmq.REQ)

    sock.Connect("tcp://localhost:57000")
    sock.Send("simple message", 0)
}

Server stucks at sock.recv()

图片转代码服务由CSDN问答提供 功能建议

我已经基于 ZeroMQ </ code> < / strong>,但现在我遇到了性能问题。 因此,我决定使用Golang重写应用程序的某些模块。 但是,当我尝试在用不同语言实现的套接字之间建立消息传递时,什么都行不通。

到目前为止,我已经进行了搜索,但是没有找到有关 ZeroMQ <的兼容性问题的任何信息。 / code>使用不同的语言。 </ p>

所以问题是:</ strong>我可以使用golang用于基于 ZeroMQ </ code>的服务器实现和使用python编写的客户端进行连接吗?
还是只使用一种语言?</ p>

编辑</ strong>:这是我试图正常工作的典型服务器和客户端</ p>

服务器:</ p>

  import zmqctx = zmq.Context()
sock = ctx.socket(zmq.REP)
sock.bind(“  tcp:// *:57000“)
msg = sock.recv()
 </ code> </ pre> 
 
 

client:</ p>

  包main 
 
import(
 zmq“ github.com/pebbe/zmq4"
)

func main(){
 
 ctx,_:= zmq.NewContext()
袜子,_:  = ctx.NewSocket(zmq.REQ)
 
 sock.Connect(“ tcp:// localhost:57000”)
 sock.Send(“简单消息”,0)
} 
 </ code> <  / pre> 
 
 

服务器卡在 sock.recv()</ code> </ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题