本文介绍了如何在MATLAB中使用jeromq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jeromq是libzmq的Java实现.我有一个从jeromq源创建的.jar文件.但是,我无法从MATLAB调用jeromq中的类.我使用过addjavaclasspath
和addjavalibrarypath
,但仍然无法使其正常工作.有没有人在MATLAB中有一个简单的工作示例?
jeromq is a Java implementation of libzmq. I have a .jar file created from the jeromq source. However, I'm unable to call a class in jeromq from MATLAB. I've used addjavaclasspath
and addjavalibrarypath
but am still not able to get it working. Does anyone have a simple working example in MATLAB?
推荐答案
在其他人感兴趣的地方,我在此处添加了答案作为参考.
I've added the answer here as for reference in case anyone else is interested.
% Author : Dheepak Krishnamurthy
% License : BSD 3 Clause
import org.zeromq.ZMQ;
ctx = zmq.Ctx();
socket = ctx.createSocket(ZMQ.REP);
socket.bind('tcp://127.0.0.1:7575');
message = socket.recv(0);
json_data = native2unicode(message.data)';
message = zmq.Msg(8);
message.put(unicode2native('Received'));
socket.send(message, 0);
socket.close()
这篇关于如何在MATLAB中使用jeromq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!