Repository: tokio-rs/tokio
File: tokio/src/net/tcp/socket.rs (Rust)

Code before:
    ///   data, and returns the doubled value from `getsockopt(2)`. As per `man
    ///   7 socket`:
    ///   > Sets or gets the maximum socket send buffer in bytes. The
    ///   > kernel doubles this value (to allow space for bookkeeping
    ///   > overhead) when it is set using `setsockopt(2)`, and this doubled
    ///   > value is returned by `getsockopt(2)`.
    ///
    /// [`set_recv_buffer_size`]: #method.set_recv_buffer_size
    pub fn recv_buffer_size(&self) -> io::Result<u32> {
        self.inner.recv_buffer_size().map(|n| n as u32)
    }

    /// Sets the linger duration of this socket by setting the `SO_LINGER` option.
    ///
    /// This option controls the action taken when a stream has unsent messages and the stream is
    /// closed. If `SO_LINGER` is set, the system shall block the process until it can transmit the
    /// data or until the time expires.
    ///
    /// If `SO_LINGER` is not specified, and the socket is closed, the system handles the call in a
    /// way that allows the process to continue as quickly as possible.
    ///
    /// This option is deprecated because setting `SO_LINGER` on a socket used with Tokio is always
    /// incorrect as it leads to blocking the thread when the socket is closed. For more details,
    /// please see:
    ///
    /// > Volumes of communications have been devoted the the intricacies of `SO_LINGER` versus
    /// > non-blocking (`O_NONBLOCK`) sockets. From what I can tell, the final word is: don't do
    /// > it. Rely on the `shutdown()`-followed-by-`read()`-eof technique instead.
    /// >
    /// > From [The ultimate `SO_LINGER` page, or: why is my tcp not reliable](https://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable)
    #[deprecated = "`SO_LINGER` causes the socket to block the thread on drop"]
    pub fn set_linger(&self, dur: Option<Duration>) -> io::Result<()> {
        self.inner.set_linger(dur)
    }

    /// Reads the linger duration for this socket by getting the `SO_LINGER`
    /// option.
    ///
    /// For more information about this option, see [`set_linger`].
    ///
    /// [`set_linger`]: TcpSocket::set_linger
    pub fn linger(&self) -> io::Result<Option<Duration>> {
        self.inner.linger()
    }

    /// Sets the value of the `TCP_NODELAY` option on this socket.
    ///
    /// If set, this option disables the Nagle algorithm. This means that segments are always
    /// sent as soon as possible, even if there is only a small amount of data. When not set,
    /// data is buffered until there is a sufficient amount to send out, thereby avoiding
    /// the frequent sending of small packets.

Review comment (suggestion):
I understand that this is a copy from somewhere and you may want to have the quote as is!
```suggestion
    /// > Volumes of communications have been devoted the intricacies of `SO_LINGER` versus
```

Code after:
    ///   data, and returns the doubled value from `getsockopt(2)`. As per `man
    ///   7 socket`:
    ///   > Sets or gets the maximum socket send buffer in bytes. The
    ///   > kernel doubles this value (to allow space for bookkeeping
    ///   > overhead) when it is set using `setsockopt(2)`, and this doubled
    ///   > value is returned by `getsockopt(2)`.
    ///
    /// [`set_recv_buffer_size`]: #method.set_recv_buffer_size
    pub fn recv_buffer_size(&self) -> io::Result<u32> {
        self.inner.recv_buffer_size().map(|n| n as u32)
    }

    /// Sets the linger duration of this socket by setting the `SO_LINGER` option.
    ///
    /// This option controls the action taken when a stream has unsent messages and the stream is
    /// closed. If `SO_LINGER` is set, the system shall block the process until it can transmit the
    /// data or until the time expires.
    ///
    /// If `SO_LINGER` is not specified, and the socket is closed, the system handles the call in a
    /// way that allows the process to continue as quickly as possible.
    ///
    /// This option is deprecated because setting `SO_LINGER` on a socket used with Tokio is always
    /// incorrect as it leads to blocking the thread when the socket is closed. For more details,
    /// please see:
    ///
    /// > Volumes of communications have been devoted to the intricacies of `SO_LINGER` versus
    /// > non-blocking (`O_NONBLOCK`) sockets. From what I can tell, the final word is: don't do
    /// > it. Rely on the `shutdown()`-followed-by-`read()`-eof technique instead.
    /// >
    /// > From [The ultimate `SO_LINGER` page, or: why is my tcp not reliable](https://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable)
    #[deprecated = "`SO_LINGER` causes the socket to block the thread on drop"]
    pub fn set_linger(&self, dur: Option<Duration>) -> io::Result<()> {
        self.inner.set_linger(dur)
    }

    /// Reads the linger duration for this socket by getting the `SO_LINGER`
    /// option.
    ///
    /// For more information about this option, see [`set_linger`].
    ///
    /// [`set_linger`]: TcpSocket::set_linger
    pub fn linger(&self) -> io::Result<Option<Duration>> {
        self.inner.linger()
    }

    /// Sets the value of the `TCP_NODELAY` option on this socket.
    ///
    /// If set, this option disables the Nagle algorithm. This means that segments are always
    /// sent as soon as possible, even if there is only a small amount of data. When not set,
    /// data is buffered until there is a sufficient amount to send out, thereby avoiding
    /// the frequent sending of small packets.