Skip to content

I/O streams need to be able to read and write simultaneously #11165

Closed
@lilyball

Description

@lilyball

TcpStream is conceptually two distinct parts: a reader and a writer. In theory you should be able to write data while in the middle of being blocked trying to read. But a TcpStream cannot be shared between tasks, so there is no way to write code to do this.

To that end, TcpStream should have a split() method that returns (TcpWriter, TcpReader) which each implement one half of the TcpStream. This would allow each half to be sent to a separate task.

One practical reason for this is to be able to wrap a TcpStream in a pair of (Port<~[u8], Chan<~[u8]>)s. This requires a split stream and two tasks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions