[zeromq-dev] how to receive a message into a static buffer?

Martin Sustrik sustrik at fastmq.com
Tue May 5 17:00:16 CEST 2009


Apps, John wrote:
> There are COBOL compilers around now -the one on OpenVMS is an
> example- which can manipulate and work with addresses. However, I
> would not like to rely on that fact and feel it better to "keep
> things simple".

There's one more reason to do without a pointers: COBOL binding would be 
used (I presume) mainly to connect legacy applications to new 
applications. If that's the case it's important to use only those 
language constructs that are expected to be available with the legacy 
compilers used to build the legacy applications.

> Here is a piece of real man's code:
> 
> 01 zmqMessageBuffO  pic x(8192). 01 zmqMessageLen    pic 9(9) comp
> value 0.
> 
> Compute zmqMessageLen = function length (zmqMessageBuffO)
> 
> call "ZMQ_RECEIVE"  using by value     zmqObj by reference
> zmqMessageBuffO by reference zmqMessageLen by value     0 by value
> ZMQ_TRUE giving ret_l_status
> The zmqMessageBuffO parameter would be the address of a local
> variable; the zmqMessageLen parameter would contain the length of
> zmqMessageBuffO. The wrapper would return an error if zmqMessageLen
> was smaller than the length returned from the message. What should
> the return status be in the case of an error?

No idea what errors are available in COBOL. Something like "buffer 
overflow"?

> If the above meets with everyone's approval, we will change the
> wrapper accordingly and send it along once it is done.
> 
> Yes, COBOL only has fixed length variables as do most high-level
> languages, I believe.
> 
> The length of a scalar variable in COBOL is 64KB. However, it is easy
> enough to create a structure, or array for that matter, of much
> greater length, so it is not a limitation.

An array of bytes may be a substitute for variable sized message, but 
it'll make the usage of 0MQ pretty annoying in COBOL, right?

Martin



More information about the zeromq-dev mailing list