Expanded top-level docs for std::net{TcpListener,TcpStream,UdpSocket}
Part of #29363
This commit is contained in:
parent
ad816f8174
commit
597bcec379
2 changed files with 58 additions and 9 deletions
|
@ -17,10 +17,25 @@ use sys_common::net as net_imp;
|
|||
use sys_common::{AsInner, FromInner, IntoInner};
|
||||
use time::Duration;
|
||||
|
||||
/// A structure which represents a TCP stream between a local socket and a
|
||||
/// remote socket.
|
||||
/// A TCP stream between a local and a remote socket.
|
||||
///
|
||||
/// The socket will be closed when the value is dropped.
|
||||
/// After creating a `TcpStream` by either [`connect`]ing to a remote host or
|
||||
/// [`accept`]ing a connection on a [`TcpListener`], data can be transmitted
|
||||
/// by [reading] and [writing] to it.
|
||||
///
|
||||
/// The connection will be closed when the value is dropped. The reading and writing
|
||||
/// portions of the connection can also be shut down individually with the [`shutdown`]
|
||||
/// method.
|
||||
///
|
||||
/// The Transmission Control Protocol is specified in [IETF RFC 793].
|
||||
///
|
||||
/// [`accept`]: ../../std/net/struct.TcpListener.html#method.accept
|
||||
/// [`connect`]: #method.connect
|
||||
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
|
||||
/// [reading]: ../../std/io/trait.Read.html
|
||||
/// [`shutdown`]: #method.shutdown
|
||||
/// [`TcpListener`]: ../../std/net/struct.TcpListener.html
|
||||
/// [writing]: ../../std/io/trait.Write.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -39,7 +54,21 @@ use time::Duration;
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct TcpStream(net_imp::TcpStream);
|
||||
|
||||
/// A structure representing a socket server.
|
||||
/// A TCP socket server, listening for connections.
|
||||
///
|
||||
/// After creating a `TcpListener` by [`bind`]ing it to a socket address, it listens
|
||||
/// for incoming TCP connections. These can be accepted by calling [`accept`] or by
|
||||
/// iterating over the [`Incoming`] iterator returned by [`incoming`].
|
||||
///
|
||||
/// The socket will be closed when the value is dropped.
|
||||
///
|
||||
/// The Transmission Control Protocol is specified in [IETF RFC 793].
|
||||
///
|
||||
/// [`accept`]: #method.accept
|
||||
/// [`bind`]: #method.bind
|
||||
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
|
||||
/// [`Incoming`]: ../../std/net/struct.Incoming.html
|
||||
/// [`incoming`]: #method.incoming
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -15,11 +15,29 @@ use sys_common::net as net_imp;
|
|||
use sys_common::{AsInner, FromInner, IntoInner};
|
||||
use time::Duration;
|
||||
|
||||
/// A User Datagram Protocol socket.
|
||||
/// A UDP socket.
|
||||
///
|
||||
/// This is an implementation of a bound UDP socket. This supports both IPv4 and
|
||||
/// IPv6 addresses, and there is no corresponding notion of a server because UDP
|
||||
/// is a datagram protocol.
|
||||
/// After creating a `UdpSocket` by [`bind`]ing it to a socket address, data can be
|
||||
/// [sent to] and [received from] any other socket address.
|
||||
///
|
||||
/// Although UDP is a connectionless protocol, this implementation provides an interface
|
||||
/// to set an address where data should be sent and received from. After setting a remote
|
||||
/// address with [`connect`], data can be sent to and received from that address with
|
||||
/// [`send`] and [`recv`].
|
||||
///
|
||||
/// As stated in the User Datagram Protocol's specification in [IETF RFC 768], UDP is
|
||||
/// an unordered, unreliable protocol; refer to [`TcpListener`] and [`TcpStream`] for TCP
|
||||
/// primitives.
|
||||
///
|
||||
/// [`bind`]: #method.bind
|
||||
/// [`connect`]: #method.connect
|
||||
/// [IETF RFC 768]: https://tools.ietf.org/html/rfc768
|
||||
/// [`recv`]: #method.recv
|
||||
/// [received from]: #method.recv_from
|
||||
/// [`send`]: #method.send
|
||||
/// [sent to]: #method.send_to
|
||||
/// [`TcpListener`]: ../../std/net/struct.TcpListener.html
|
||||
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -582,9 +600,11 @@ impl UdpSocket {
|
|||
/// Receives data on the socket from the remote address to which it is
|
||||
/// connected.
|
||||
///
|
||||
/// The `connect` method will connect this socket to a remote address. This
|
||||
/// The [`connect`] method will connect this socket to a remote address. This
|
||||
/// method will fail if the socket is not connected.
|
||||
///
|
||||
/// [`connect`]: #method.connect
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
|
|
Loading…
Add table
Reference in a new issue