Skip to content

Commit 758355f

Browse files
committed
Refactor Socket::peek
1 parent d8601a8 commit 758355f

File tree

3 files changed

+1
-9
lines changed

3 files changed

+1
-9
lines changed

src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl Socket {
390390
/// On success, returns the number of bytes peeked and the address from
391391
/// whence the data came.
392392
pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> {
393-
self.inner().peek_from(buf)
393+
self.recv_from_with_flags(buf, sys::MSG_PEEK)
394394
}
395395

396396
/// Sends data on the socket to a connected peer.

src/sys/unix.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,6 @@ pub struct Socket {
578578
}
579579

580580
impl Socket {
581-
pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> {
582-
recv_from(self.fd, buf, libc::MSG_PEEK)
583-
}
584-
585581
#[cfg(not(target_os = "redox"))]
586582
pub fn recv_from_vectored(
587583
&self,

src/sys/windows.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,6 @@ pub struct Socket {
414414
}
415415

416416
impl Socket {
417-
pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> {
418-
recv_from(self.socket, buf, MSG_PEEK)
419-
}
420-
421417
pub fn recv_from_vectored(
422418
&self,
423419
bufs: &mut [IoSliceMut<'_>],

0 commit comments

Comments
 (0)