pub struct TcpListener { /* private fields */ }
Expand description
TcpListener
Implementations§
Source§impl TcpListener
impl TcpListener
Sourcepub fn bind_with_config<A: ToSocketAddrs>(
addr: A,
opts: &ListenerOpts,
) -> Result<Self>
pub fn bind_with_config<A: ToSocketAddrs>( addr: A, opts: &ListenerOpts, ) -> Result<Self>
Bind to address with config
Sourcepub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>
Bind to address
Sourcepub async fn accept(&self) -> Result<(TcpStream, SocketAddr)>
pub async fn accept(&self) -> Result<(TcpStream, SocketAddr)>
Accept
Sourcepub async fn cancelable_accept(
&self,
c: CancelHandle,
) -> Result<(TcpStream, SocketAddr)>
pub async fn cancelable_accept( &self, c: CancelHandle, ) -> Result<(TcpStream, SocketAddr)>
Cancelable accept
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address that this listener is bound to.
Sourcepub async fn readable(&self, relaxed: bool) -> Result<()>
pub async fn readable(&self, relaxed: bool) -> Result<()>
Wait for read readiness. Note: Do not use it before every io. It is different from other runtimes!
Everytime call to this method may pay a syscall cost. In uring impl, it will push a PollAdd op; in epoll impl, it will use use inner readiness state; if !relaxed, it will call syscall poll after that.
If relaxed, on legacy driver it may return false positive result. If you want to do io by your own, you must maintain io readiness and wait for io ready with relaxed=false.
Sourcepub fn from_std(stdl: TcpListener) -> Result<Self>
pub fn from_std(stdl: TcpListener) -> Result<Self>
Creates new TcpListener
from a std::net::TcpListener
.
Trait Implementations§
Source§impl AsRawFd for TcpListener
impl AsRawFd for TcpListener
Source§impl Debug for TcpListener
impl Debug for TcpListener
Source§impl Drop for TcpListener
impl Drop for TcpListener
Auto Trait Implementations§
impl !Freeze for TcpListener
impl !RefUnwindSafe for TcpListener
impl !Send for TcpListener
impl !Sync for TcpListener
impl Unpin for TcpListener
impl !UnwindSafe for TcpListener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more