[zeromq-dev] xpub and xsub example
Pieter Hintjens
ph at imatix.com
Mon Jan 14 23:55:43 CET 2013
>From https://github.com/imatix/zguide/blob/master/examples/C/lvcache.c:
int main (void)
{
zctx_t *context = zctx_new ();
void *frontend = zsocket_new (context, ZMQ_SUB);
zsocket_bind (frontend, "tcp://*:5557");
void *backend = zsocket_new (context, ZMQ_XPUB);
zsocket_bind (backend, "tcp://*:5558");
On Mon, Jan 14, 2013 at 11:39 PM, Mohit Jaggi <mohitjaggi at gmail.com> wrote:
> Thanks Charles(new to IRC, thanks for the advice!) and Peter. The example
> you pointed out does use XPUB/XSUB. Am I missing something?
>
>
> On Mon, Jan 14, 2013 at 2:25 PM, Charles Remes <lists at chuckremes.com> wrote:
>>
>> On Jan 14, 2013, at 4:10 PM, Mohit Jaggi <mohitjaggi at gmail.com> wrote:
>>
>> Hi All,
>> I am looking for examples of xpub and xsub. My use case is that multiple
>> threads in a process produce data that needs to be published over a TCP
>> socket. I was thinking of letting them call "send" but it seems that that is
>> not thread-safe. From the guide, it appears I can use inproc+xpub socket
>> from producers to a proxy and let subscribers connect over TCP/xsub.
>> However, there is no example code.
>>
>>
>> I answered your question on irc. When asking a question, you should stick
>> around for more than 5m to get an answer.
>>
>> Create a forwarder device that all of your PUB sockets connect to. All SUB
>> sockets should then subscribe to that forwarder. You do *not* need to mess
>> with XPUB and XSUB sockets.
>>
>> See here:
>>
>> http://api.zeromq.org/3-2:zmq-proxy
>>
>> and
>>
>> http://zguide.zeromq.org/page:all#Intermediaries-and-Proxies
>>
>> cr
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
More information about the zeromq-dev
mailing list