Skip to content

Commit

Permalink
net: improve discoverability of TcpSocket (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Jan 28, 2021
1 parent 4968f59 commit cd75268
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 0 additions & 2 deletions tokio/src/net/addr.rs
Expand Up @@ -8,8 +8,6 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV
/// # DNS
///
/// Implementations of `ToSocketAddrs` for string types require a DNS lookup.
/// These implementations are only provided when Tokio is used with the
/// **`net`** feature flag.
///
/// # Calling
///
Expand Down
7 changes: 4 additions & 3 deletions tokio/src/net/tcp/listener.rs
Expand Up @@ -64,17 +64,18 @@ impl TcpListener {
/// method.
///
/// The address type can be any implementor of the [`ToSocketAddrs`] trait.
/// Note that strings only implement this trait when the **`net`** feature
/// is enabled, as strings may contain domain names that need to be resolved.
///
/// If `addr` yields multiple addresses, bind will be attempted with each of
/// the addresses until one succeeds and returns the listener. If none of
/// the addresses succeed in creating a listener, the error returned from
/// the last attempt (the last address) is returned.
///
/// This function sets the `SO_REUSEADDR` option on the socket.
///
/// To configure the socket before binding, you can use the [`TcpSocket`]
/// type.
///
/// [`ToSocketAddrs`]: trait@crate::net::ToSocketAddrs
/// [`TcpSocket`]: struct@crate::net::TcpSocket
///
/// # Examples
///
Expand Down
19 changes: 11 additions & 8 deletions tokio/src/net/tcp/stream.rs
Expand Up @@ -25,7 +25,8 @@ cfg_net! {
/// A TCP stream between a local and a remote socket.
///
/// A TCP stream can either be created by connecting to an endpoint, via the
/// [`connect`] method, or by [accepting] a connection from a [listener].
/// [`connect`] method, or by [accepting] a connection from a [listener]. A
/// TCP stream can also be created via the [`TcpSocket`] type.
///
/// Reading and writing to a `TcpStream` is usually done using the
/// convenience methods found on the [`AsyncReadExt`] and [`AsyncWriteExt`]
Expand All @@ -34,6 +35,7 @@ cfg_net! {
/// [`connect`]: method@TcpStream::connect
/// [accepting]: method@crate::net::TcpListener::accept
/// [listener]: struct@crate::net::TcpListener
/// [`TcpSocket`]: struct@crate::net::TcpSocket
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
///
Expand Down Expand Up @@ -76,16 +78,17 @@ impl TcpStream {
/// Opens a TCP connection to a remote host.
///
/// `addr` is an address of the remote host. Anything which implements the
/// [`ToSocketAddrs`] trait can be supplied as the address. Note that
/// strings only implement this trait when the **`net`** feature is enabled,
/// as strings may contain domain names that need to be resolved.
/// [`ToSocketAddrs`] trait can be supplied as the address. If `addr`
/// yields multiple addresses, connect will be attempted with each of the
/// addresses until a connection is successful. If none of the addresses
/// result in a successful connection, the error returned from the last
/// connection attempt (the last address) is returned.
///
/// If `addr` yields multiple addresses, connect will be attempted with each
/// of the addresses until a connection is successful. If none of the
/// addresses result in a successful connection, the error returned from the
/// last connection attempt (the last address) is returned.
/// To configure the socket before connecting, you can use the [`TcpSocket`]
/// type.
///
/// [`ToSocketAddrs`]: trait@crate::net::ToSocketAddrs
/// [`TcpSocket`]: struct@crate::net::TcpSocket
///
/// # Examples
///
Expand Down

0 comments on commit cd75268

Please sign in to comment.