Yes, the pull socket is in only one thread. However, there seems to be a sweet 
spot for when I am sending strings, with regards to timeout, as I increased it 
from -1 to 500 ms in

zsock_t *which = (zsock_t *) zpoller_wait (poller, 500);

And I sent 1 mil short strings (< 50 chars) and it seems to be working OK. I 
tried many times and seems OK.
However, I switched to sending chunks of memory using zsock_brecv and 
zsock_bsend. And I am back to no reaction. At all.

But I will recompile the library with the SERVER/CLIENT draft and see if that 
works better.

Thanks.

Johnny
________________________________
From: Brett Viren
Sent: Tuesday, April 21, 2020 9:21 PM
To: Johnny Depp
Cc: [email protected]
Subject: Re: [zeromq-dev] CZMQ question re: use of zpoller

Hi,

Johnny Depp <[email protected]> writes:

> [...code...]

This code looks okay to me.

> My problem is this: When I use this code in two separate simple applications, 
> the above code
> works. However, when I move the server into a larger application with 
> multiple threads, it is
> starting to behave randomly: it works in some cases, but it mostly doesn't. 
> The poller does
> detect anything on wait.

This raises a possible flag.  Is the PULL (server) socket being used
from different threads?  If so, you'll need to constrain its entire
lifetime to a single thread.

Or, if you need thread-safety you may switch to SERVER/CLIENT (draft
sockets).

With your code as shown I think you may need to simply change the socket
types from PUSH/PULL to CLIENT/SERVER to test this (and maybe rebuild
with "draft" sockets if they aren't in your libzmq and libczmq builds
already).


Cheers!
-Brett.
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to