tcp: add ascyc fn TcpListener::accept (#1242)

Refs: #1209
This commit is contained in:
Carl Lerche
2019-07-03 09:49:56 -07:00
committed by GitHub
parent c531865d2c
commit 3e898f58a5
4 changed files with 46 additions and 0 deletions
+1
View File
@@ -2,6 +2,7 @@
#![deny(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![cfg_attr(test, deny(warnings))]
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
#![feature(async_await)]
//! TCP bindings for `tokio`.
//!
+18
View File
@@ -110,6 +110,24 @@ impl TcpListener {
Poll::Ready(Ok((io, addr)))
}
/// Accept a new incoming connection from this listener.
///
/// This function will yield once a new TCP connection is established. When
/// established, the corresponding [`TcpStream`] and the remote peer's
/// address will be returned.
///
/// [`TcpStream`]: ../struct.TcpStream.html
///
/// # Examples
///
/// ```
/// unimplemented!();
/// ```
pub async fn accept(&mut self) -> io::Result<(TcpStream, SocketAddr)> {
use async_util::future::poll_fn;
poll_fn(|cx| self.poll_accept(cx)).await
}
/// Attempt to accept a connection and create a new connected `TcpStream` if
/// successful.
///