JeroMQ subscriber MATLAB

188 Views Asked by At

I have latest JeroMQ imported in Matlab and Im trying to connect to a C# program running ZeroMQ publisher.

I dont receive any messages and Im sure the publisher is sending. As it seems the socket is connected, I cant probably set socket options correctly. Any help is appreciated.

import org.zeromq.*

context = zmq.Ctx();
socket = context.createSocket(ZMQ.SUB);  

% ZMQ.SUBSCRIBE is option number 6, cant import this in matlab
socket.xsetsockopt(6, unicode2native('', 'utf8'));
socket.connect('tcp://....');

message = socket.recv(1);  % this receives empty message
message = socket.recv(0);  % this blocks and never receives
1

There are 1 best solutions below

1
reicja On

The following works for me

import org.zeromq.*

context = ZMQ.context(1);
socket = context.socket(ZMQ.SUB);  
socket.subscribe('')
socket.connect('tcp://...');
socket.recvStr(0)