Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: create a split dealer socket #194

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP: create a split dealer socket #194

wants to merge 1 commit into from

Conversation

rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Jul 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant