From 158e7785ae104d6014c9f333bc0011184ae73e64 Mon Sep 17 00:00:00 2001 From: PerfectLaugh Date: Thu, 21 May 2020 17:14:19 +0800 Subject: [PATCH] fix: correct recv_from_with_flags and sendto 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 b7e48ff9..531bb876 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -287,8 +287,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. @@ -345,8 +349,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) } // ================================================