Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,22 @@ impl TcpListener {
/// is established. When established, the corresponding [`TcpStream`] and the
/// remote peer's address will be returned.
///
/// # Errors
///
/// Some errors returned by this function relate to a single incoming
/// connection that failed before it could be accepted, such as one aborted
/// by the peer ([`ConnectionAborted`]). Such an error does not indicate a
/// problem with the listener itself, which remains usable. Code serving a
/// long-lived listener will usually want to log the error and continue
/// accepting connections rather than treat it as fatal. Which errors can
/// occur this way is platform-specific.
///
/// On Unix, [`Interrupted`] errors are retried internally rather than being
/// returned.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to start documenting the set of errors, then we should probably also mention that it can fail with an error if the FD limit has been reached, in which case the call can be retried once other fds have been closed (often done via a timeout).

///
/// [`ConnectionAborted`]: io::ErrorKind::ConnectionAborted
/// [`Interrupted`]: io::ErrorKind::Interrupted
///
/// # Examples
///
/// ```no_run
Expand All @@ -902,6 +918,11 @@ impl TcpListener {
/// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to
/// calling [`TcpListener::accept`] in a loop.
///
/// # Errors
///
/// Each connection yielded by the iterator can fail for the same reasons as
/// [`TcpListener::accept`]; see its documentation for details.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -937,6 +958,11 @@ impl TcpListener {
/// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to
/// calling [`TcpListener::accept`] in a loop.
///
/// # Errors
///
/// Each connection yielded by the iterator can fail for the same reasons as
/// [`TcpListener::accept`]; see its documentation for details.
///
/// # Examples
///
/// ```no_run
Expand Down
Loading