Repository navigation
Conversation
| /// Note that the delay is expressed as Duration from user's perspective | ||
| /// the call rounds it down to the nearest second expressible as a `c_int`. | ||
| /// This defers accepting an incoming connection that has not yet received data. | ||
| /// The `accept` argument specifies an approximate delay. |
There was a problem hiding this comment.
| /// The `accept` argument specifies an approximate delay. | |
| /// The `accept` argument specifies a lower bound on the timeout. The actual timeout may be significantly larger. |
Edit: see below, this suggestion isn't good alone The timeout will always be at least what you specified, the "weird" behavior is only that the delay might be significantly larger (up to 120 seconds longer, with the current implementation, but I expect that to be an implementation detail)
There was a problem hiding this comment.
actually it's also not a minimum, a large duration will be capped at 255 retransmits, so this really is just a hint, the current wording is probably fine, maybe worth adding "may be significantly longer or shorter" because this isn't like "sleep(n) is approximate", this is its own class of approximate
| #[unstable(feature = "tcp_deferaccept", issue = "119639")] | ||
| #[cfg(target_os = "linux")] | ||
| fn set_deferaccept(&self, accept: Duration) -> io::Result<()>; | ||
| fn set_defer_accept(&self, accept: Duration) -> io::Result<()>; |
There was a problem hiding this comment.
| fn set_defer_accept(&self, accept: Duration) -> io::Result<()>; | |
| fn set_defer_accept(&self, timeout: Duration) -> io::Result<()>; |
accept is a weird name for this argument IMO. It's fine if there's precedence, but I think that something like timeout or delay or something would be more clear.
| /// This option can also limit the number of attempts TCP makes to complete a | ||
| /// connection, so connections may be dropped if more retransmissions are needed. |
There was a problem hiding this comment.
| /// This option can also limit the number of attempts TCP makes to complete a | |
| /// connection, so connections may be dropped if more retransmissions are needed. | |
| /// This option is useful to limit the number of attempts TCP makes to complete a | |
| /// connection, so connections may be dropped if more retransmissions are needed. |
| /// let stream = TcpStream::connect("127.0.0.1:8080") | ||
| /// .expect("Couldn't connect to the server..."); | ||
| /// stream.set_deferaccept(Duration::from_secs(1u64)).expect("set_deferaccept call failed"); | ||
| /// stream.set_defer_accept(Duration::from_secs(1u64)).expect("set_defer_accept call failed"); |
There was a problem hiding this comment.
This seems like a weird example -- this is suppose to be set on a socket before bind(...), not on the client socket?
Address review points in #154834
I've chosen
Result<Option<Duration>>as noted in #154834 (comment), but we may want to discuss further and I'd like to hear opinions.r? @Mark-Simulacrum @the8472