[zeromq-dev] zeromq-dev Digest, Vol 24, Issue 13

Georger, Joseph joseph.georger at stresearch.com
Sat Mar 24 17:10:41 CET 2018


I have looked at the self test and did not see an example where frames were being written and a picture received. Here is what happens when I run the code below. As you can see, only the string comes through when sending frames to a picture.

Testing picture to picture send/receive:
Sending 5, topic, 3
Received 5, topic, 3
Testing frame to picture send/receive:
Received 0, topic, 0

#include "czmq.h"
#include <iostream>

int main(void) {
	// Create two PAIR sockets and connect over inproc
	zsock_t *output = zsock_new_pair("@inproc://zsock.test");
	assert (output);
	zsock_t *input = zsock_new_pair(">inproc://zsock.test");
	assert (input);
	
	// picture to picture test
	std::cout << "Testing picture to picture send/receive:\n";
	int num1 = 5;
	uint32_t num2 = 3;
	std::cout << "Sending " << num1 << ", topic, " << num2 << std::endl;
	zsock_send(output, "is4", num1, "topic", num2);

	int rnum1;
	char *rstr;
	uint32_t rnum2;
	int rc = zsock_recv(input, "is4", &rnum1, &rstr, &num2);
	assert(rc == 0);
	std::cout << "Received " << rnum1 << ", " << rstr << ", " << num2 << std::endl;
	freen(rstr);

	// frames to picture test
	std::cout << "Testing frame to picture send/receive:\n";
	zmsg_t *msg = zmsg_new();
	assert(msg);
	rc = zmsg_addmem(msg, &num1, sizeof(num1));
	assert(rc == 0);
	rc = zmsg_addmem(msg, "topic", 5);
	assert(rc == 0);
	rc = zmsg_addmem(msg, &num2, sizeof(num2));
	assert(rc == 0);
	rc = zmsg_send(&msg, output);
	assert(rc == 0);

	rnum1 = 0;
	rnum2 = 0;
	rc = zsock_recv(input, "is4", &rnum1, &rstr, &num2);
	assert(rc == 0);
	std::cout << "Received " << rnum1 << ", " << rstr << ", " << num2 << std::endl;
	freen(rstr);

	zsock_destroy(&input);
	zsock_destroy(&output);
}

Thanks,
Joe
 

    
    Message: 13
    Date: Sat, 24 Mar 2018 10:11:02 +0000
    From: Luca Boccassi <luca.boccassi at gmail.com>
    To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
    Subject: Re: [zeromq-dev] zframe compatible w/zsock picture?
    Message-ID: <1521886262.14111.85.camel at gmail.com>
    Content-Type: text/plain; charset="utf-8"
    
    On Fri, 2018-03-23 at 22:25 +0000, Georger, Joseph wrote:
    > Just a quick question, I was starting to write send & receive using
    > zframes, but came across the ?picture? concept in zsock. I was
    > sending three zframes, using addmem to construct the zmsg: char *
    > topic, uint32_t length in bytes, char * for msg.
    > 
    > I wrote the receiver using pictures,
    > zsock_receive(socket, ?s4s?, &sz, &topic, &payload)
    > 
    > topic came through, but sz was 0. Should this in theory work, can I
    > receive a frame containing a uint32_t with the picture paradigm? Can
    > I intermix a zmsg/zframe sender with a picture receiver (and vice
    > versa)? The docs imply yes: ?The picture is a string that defines the
    > type of each frame.?
    > 
    > Thanks,
    > Joe
    
    Yes, see selftest for an example:
    
    https://github.com/zeromq/czmq#zsock---high-level-socket-api-that-hides-libzmq-contexts-and-sockets
    
    -- 
    Kind regards,
    Luca Boccassi
    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: signature.asc
    Type: application/pgp-signature
    Size: 488 bytes
    Desc: This is a digitally signed message part
    URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180324/07c46638/attachment-0001.sig>
    
    ------------------------------
    
    Subject: Digest Footer
    
    _______________________________________________
    zeromq-dev mailing list
    zeromq-dev at lists.zeromq.org
    https://lists.zeromq.org/mailman/listinfo/zeromq-dev
    
    
    ------------------------------
    
    End of zeromq-dev Digest, Vol 24, Issue 13
    ******************************************
    



More information about the zeromq-dev mailing list