diff --git a/src/tcp.rs b/src/tcp.rs index 6fe7d2cf9..7fb28b21e 100644 --- a/src/tcp.rs +++ b/src/tcp.rs @@ -360,3 +360,41 @@ impl Stream for TcpStream { self.ready.schedule(task) } } + +#[cfg(unix)] +mod sys { + use std::os::unix::prelude::*; + use super::{TcpStream, TcpListener}; + + impl AsRawFd for TcpStream { + fn as_raw_fd(&self) -> RawFd { + self.source.io().as_raw_fd() + } + } + + impl AsRawFd for TcpListener { + fn as_raw_fd(&self) -> RawFd { + self.listener.io().as_raw_fd() + } + } +} + +#[cfg(windows)] +mod sys { + // TODO: let's land these upstream with mio and then we can add them here. + // + // use std::os::windows::prelude::*; + // use super::{TcpStream, TcpListener}; + // + // impl AsRawHandle for TcpStream { + // fn as_raw_handle(&self) -> RawHandle { + // self.source.io().as_raw_handle() + // } + // } + // + // impl AsRawHandle for TcpListener { + // fn as_raw_handle(&self) -> RawHandle { + // self.listener.io().as_raw_handle() + // } + // } +} diff --git a/src/udp.rs b/src/udp.rs index 52d957eaa..2c0009aaf 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -249,3 +249,29 @@ impl Stream for UdpSocket { self.ready.schedule(task) } } + +#[cfg(unix)] +mod sys { + use std::os::unix::prelude::*; + use super::UdpSocket; + + impl AsRawFd for UdpSocket { + fn as_raw_fd(&self) -> RawFd { + self.source.io().as_raw_fd() + } + } +} + +#[cfg(windows)] +mod sys { + // TODO: let's land these upstream with mio and then we can add them here. + // + // use std::os::windows::prelude::*; + // use super::UdpSocket; + // + // impl AsRawHandle for UdpSocket { + // fn as_raw_handle(&self) -> RawHandle { + // self.source.io().as_raw_handle() + // } + // } +}