( sample code although not complete here: http://pastebin.com/1xXYn4x3)
binds on a tcp host port
in a while loop receives 10 messages
closes the socket & closes the context
sleeps (for say 2 secs)
connects to xrep end
in while loop sends a message containing a singe no (which is incremented every time)
sleeps (for say 1.5 secs)
for xreq end ; we start it , wait for it to finish, sleeps (for say 10 sec) & then start it again
for xreq end ; we start the xreq end and keep it running.
xreq receives msgs: 1-10, 11-20, 21-30, 96-105 (multiple runs give different results)
some older messages are preserved through xrep start/shutdown cycles. maybe the check for peer is down (which takes some time - alteast a few secs) occurs early & messages are not entered in the queue at all. even though the xreq code notices that the peer is down & starts dropping messages apparently the ones already in queue are left untouched.