mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
net: improve discoverability of TcpSocket (#3471)
This commit is contained in:
parent
4968f59af6
commit
cd7526873c
@ -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
|
||||
///
|
||||
|
@ -64,9 +64,6 @@ 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
|
||||
@ -74,7 +71,11 @@ impl TcpListener {
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
|
@ -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`]
|
||||
@ -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
|
||||
///
|
||||
@ -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
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user