From b3badc7d3d599746a3632666876f1a253476c3c7 Mon Sep 17 00:00:00 2001 From: PerfectLaugh Date: Thu, 21 May 2020 23:41:26 +0800 Subject: [PATCH] fix: correct recv_from_with_flags and sendto (#81) The behavior is wrong with original function. Fix with simple lines. --- src/socket.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index 59d74cc2..ebe3f60d 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -285,8 +285,12 @@ impl Socket { /// `recvfrom` call. /// /// [`recv_from`]: #method.recv_from - pub fn recv_from_with_flags(&self, buf: &mut [u8], flags: i32) -> io::Result { - self.inner.recv(buf, flags) + pub fn recv_from_with_flags( + &self, + buf: &mut [u8], + flags: i32, + ) -> io::Result<(usize, SockAddr)> { + self.inner.recv_from(buf, flags) } /// Receives data from the socket, without removing it from the queue. @@ -343,8 +347,8 @@ impl Socket { /// `sendto` call. /// /// [`send_to`]: #method.send_to - pub fn send_to_with_flags(&self, buf: &mut [u8], flags: i32) -> io::Result { - self.inner.recv(buf, flags) + pub fn send_to_with_flags(&self, buf: &[u8], addr: &SockAddr, flags: i32) -> io::Result { + self.inner.send_to(buf, flags, addr) } // ================================================