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

TcpStream clones count as same Evented handler #1193

Closed
khionu opened this issue Dec 7, 2019 · 2 comments
Closed

TcpStream clones count as same Evented handler #1193

khionu opened this issue Dec 7, 2019 · 2 comments

Comments

@khionu
Copy link

khionu commented Dec 7, 2019

I'm not sure if this counts as a bug or if it's just a detail that needs to be documented, but this is apparently not possible.

Example:

let mut tx = TcpStream::connect(...)?;
let mut rx = stream.try_clone()?;

poll.register(&tx, Token(1), Ready::writable(), PollOpt::edge())?;
poll.register(&rx, Token(2), Ready::readable(), PollOpt::edge())?; // Error: bug or illegal?

Error:

Os { code: 87, kind: Other, message: "The parameter is incorrect." }

The issue I see is that the docs say that the clone produces an independent handle, which should mean this is allowed.

System: Windows 10 1903 x64
Mio: 0.6.21

@Thomasdezeeuw
Copy link
Collaborator

@khionu try_clone has many problems, this could very well be one of them. For Mio 0.7 try_clone is going to be removed, see #1178 and #1184. Based on that I'm going to close this.

If you still need to split the reading and writing side I would suggest an Arc and then you can read and write safely.

@khionu
Copy link
Author

khionu commented Dec 7, 2019

Alrighty, thank you very much.

@khionu khionu closed this as completed Dec 7, 2019
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

No branches or pull requests

2 participants