[zeromq-dev] STREAM sockets merge two chunks of data on a single recv

Amr Ali amr.ali.cc at gmail.com
Tue Mar 3 22:09:01 CET 2015

While testing an API implementation where I use 0MQ STREAM socket to 
send data to a server that uses vanilla TCP socket to receive the data I 
noticed something peculiar that failed my tests.

In my tests I use a 0MQ STREAM socket to mock the service's server TCP 

So my API function does multiple consecutive `send()`s (exactly 3), and 
in my unit test function I do 4 `recv()`s (the first is to get the 
client identity). The 3rd `recv()` returns the data both the 2nd and 3rd 
`send()` sent, and the 4th `recv()` times out.

API sends:

[First Message]
+++ some code +++
[Second Message]
+++ some code +++
[Third Message]

Test Receives:

[Client Identity -- no data]
+++ some asserts +++
[First Message]
+++ some asserts +++
[Second Message + Third Message]
+++ some asserts +++
[This recv raises EAGAIN]

Does libzmq internally make sure to flush data on a STREAM socket before 
other `send()` calls?

More information about the zeromq-dev mailing list