help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help-octave Digest, Vol 157, Issue 40


From: Ardid, Salva
Subject: Re: Help-octave Digest, Vol 157, Issue 40
Date: Mon, 22 Apr 2019 16:19:33 +0000

El dilluns, 22 d’abril de 2019, a les 11:47:48 EDT, John Donoghue va escriure:

  On 4/22/19 9:41 AM, address@hidden wrote:
  > Message: 2
  > Date: Sun, 21 Apr 2019 23:54:09 +0000
  > From: "Ardid, Salva"<address@hidden>
  > To:"address@hidden"  <address@hidden>
  > Subject: Workaround missing functions in the zeromq package
  > Message-ID: <address@hidden>
  > Content-Type: text/plain; charset="utf-8"
  >
  > Hi,
  >
  > I started working to support Octave in Transplant using the zeromq package 
in Octave Forge. It?s the first time I use anything related to ZMQ and I 
reached a point where I?m stacked because Transplant uses zmq_msg_init, 
zmq_msg_recv, zmq_msg_data and zmq_msg_close, which are not yet supported in 
Octave?s package.
  >
  > So, I wonder, would there be some way to implement the same functionality 
just using zmq_recv?
  >
  > For the case it is useful, this is the piece of code I would need to adapt:
  >
  > msg = libstruct('zmq_msg_t', struct('hidden', zeros(1, 64, 'uint8')));
  > calllib('libzmq', 'zmq_msg_init', msg); % always returns 0
  > msglen = calllib('libzmq', 'zmq_msg_recv', msg, obj.socket, 0);
  > assert(msglen >= 0, obj.errortext('zmq_msg_recv'));
  > msgptr = calllib('libzmq', 'zmq_msg_data', msg);
  > if not(msgptr.isNull)
  >      setdatatype(msgptr, 'uint8Ptr', 1, msglen);
  >      str = uint8(msgptr.Value);
  > else
  >      str = uint8([]);
  > end
  > err = calllib('libzmq', 'zmq_msg_close', msg);
  > assert(err == 0, obj.errortext('zmq_msg_close'));
  >
  >
  > [Transplant also uses zmq contexts, which are not supported in the Octave 
package either. Although I?m not totally sure, I think this shouldn?t be 
strictly needed to make it work]
  >
  > Any help on this is very much appreciated!
  >
  > Thanks in advance and best, Salva
  
  the octave zmq package uses a zmq context within the package, but 
  doesn't expose it to the user. The same goes for the zmq_msg_xxxx 
  functions - they are used internally, but the user doesnt have direct 
  access to them.
  
  So the user (after creating the zmq socket) can just call,   msg = 
  zmq_recv(sock, 100) to read up to 100 bytes to msg, rather than having 
  to prep a msg_t.
  
  The examples and documentation that come with the package give a 
  overview of using it, and what calls are not required. [1]
  
  
  [1] https://octave.sourceforge.io/zeromq/package_doc/
  
I see. I read the docs but I guess what I missed was UP TO in "msg = 
  zmq_recv(sock, 100) to read up to 100 bytes to msg"

That's awesome! 

Thank you very much,
Salva
  
  
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]