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

Apps, John john.apps at hp.com
Tue May 5 14:15:26 CEST 2009


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".

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?

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.

---- John Apps | Hewlett-Packard | John.Apps at HP.com | +49 171 869 1813 ----


-----Original Message-----
From: pieterh at gmail.com [mailto:pieterh at gmail.com] On Behalf Of Pieter Hintjens
Sent: Tuesday, May 05, 2009 12:00
To: Martin Sustrik
Cc: Apps, John; zeromq-dev at lists.zeromq.org
Subject: Re: [zeromq-dev] how to receive a message into a static buffer?

On Tue, May 5, 2009 at 11:01 AM, Martin Sustrik <sustrik at fastmq.com> wrote:

>> 1. pass the address and length of a local variable to the wrapper and
>> have it copy the data to the local variable
>
> Yes, however, if the message is larger then the variable, it'll result
> in error. I belive you are speaking about COBOL here, right? IIRC the
> variables in COBOL are fixed-length, so it may be actually the right way
> to handle the issue.

COBOL can work with pointers in various ways; it does not (or did not,
maybe it changed), have pointer operators as such but it can pass
32-bit or 64-bit values to subroutines which if written in C can do
pointer work on them.  To actually access the data behind the pointer
would require a call to a copy function.  The maximum size of a COBOL
variable depends on the compiler.  2^^16 used to be typical.

-Pieter



More information about the zeromq-dev mailing list