zmq.rs icon indicating copy to clipboard operation
zmq.rs copied to clipboard

WIP: create a split dealer socket

Open rgbkrk opened this issue 1 year ago • 0 comments

There are cases when using the DealerSocket when we need to be able to both continuously send and receive messages without deadlocking either one. For example, with code like this:

socket.send(message).await?;
let reply = socket.recv().await?;

If we don't get a reply back for that message type we can no longer send out other messages. An approach seen in other code bases is to introduce a .split() method that breaks up reading and writing. This is a start to that.

An alternative would be to make a try_clone like TcpStream has which:

Creates a new independently owned handle to the underlying socket.

The returned TcpStream is a reference to the same stream that this object references. Both handles will read and write the same stream of data, and options set on one stream will be propagated to the other stream.

rgbkrk avatar Jul 12 '24 19:07 rgbkrk