-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
UdpSocket split support #1226
UdpSocket split support #1226
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable though I'd like to have @jonhoo or @carllerche look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thanks! I tracked polish questions on #1250.
Why the API of
fn split(self) -> (UdpSocketRecvHalf, UdpSocketSendHalf)
fn split(&mut self) -> (ReadHalf, WriteHalf) What's more, fn send_to(
&'_ mut self,
buf: &'_ [u8],
target: &'_ SocketAddr
) -> impl Future<Output = Result<usize, Error>>
fn send_to<A>(
&'_ mut self,
buf: &'_ [u8],
target: A
) -> impl Future<Output = Result<usize, Error>> where
A: ToSocketAddrs I have written a patch to make these API feel consistent, but I'm not sure whether it is considered a bug. |
Hi,
Originally But I think it would problematic if If we change
The |
The UDP counterpart of #1217.
A specialized split is implemented for
UdpSocket
, making it possible to receive and send on the socket concurrently, even from two different tasks.There are no
AsyncRead
orAsyncWrite
like traits forUdpSocket
. So the halves have receive or send methods same with the socket. The methods return the same future types with theirUdpSocket
equivalents.