Skip to content

Replace duplicate() by try_clone() in std::net. #1013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2015
Merged
Changes from all commits
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
14 changes: 7 additions & 7 deletions text/0517-io-os-reform.md
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ impl TcpStream {
fn peer_addr(&self) -> io::Result<SocketAddr>;
fn local_addr(&self) -> io::Result<SocketAddr>;
fn shutdown(&self, how: Shutdown) -> io::Result<()>;
fn duplicate(&self) -> io::Result<TcpStream>;
fn try_clone(&self) -> io::Result<TcpStream>;
}

impl Read for TcpStream { ... }
Expand All @@ -1619,8 +1619,8 @@ impl<'a> Write for &'a TcpStream { ... }
#[cfg(windows)] impl AsRawSocket for TcpStream { ... }
```

* `clone` has been replaced with a `duplicate` function. The implementation of
`duplicate` will map to using `dup` on Unix platforms and
* `clone` has been replaced with a `try_clone` function. The implementation of
`try_clone` will map to using `dup` on Unix platforms and
`WSADuplicateSocket` on Windows platforms. The `TcpStream` itself will no
longer be reference counted itself under the hood.
* `close_{read,write}` are both removed in favor of binding the `shutdown`
Expand All @@ -1646,7 +1646,7 @@ into the `TcpListener` structure. Specifically, this will be the resulting API:
impl TcpListener {
fn bind<A: ToSocketAddrs>(addr: &A) -> io::Result<TcpListener>;
fn local_addr(&self) -> io::Result<SocketAddr>;
fn duplicate(&self) -> io::Result<TcpListener>;
fn try_clone(&self) -> io::Result<TcpListener>;
fn accept(&self) -> io::Result<(TcpStream, SocketAddr)>;
fn incoming(&self) -> Incoming;
}
Expand All @@ -1663,7 +1663,7 @@ Some major changes from today's API include:

* The static distinction between `TcpAcceptor` and `TcpListener` has been
removed (more on this in the [socket][Sockets] section).
* The `clone` functionality has been removed in favor of `duplicate` (same
* The `clone` functionality has been removed in favor of `try_clone` (same
caveats as `TcpStream`).
* The `close_accept` functionality is removed entirely. This is not currently
implemented via `shutdown` (not supported well across platforms) and is
Expand All @@ -1690,7 +1690,7 @@ impl UdpSocket {
fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)>;
fn send_to<A: ToSocketAddrs>(&self, buf: &[u8], addr: &A) -> io::Result<usize>;
fn local_addr(&self) -> io::Result<SocketAddr>;
fn duplicate(&self) -> io::Result<UdpSocket>;
fn try_clone(&self) -> io::Result<UdpSocket>;
}

#[cfg(unix)] impl AsRawFd for UdpSocket { ... }
Expand All @@ -1705,7 +1705,7 @@ Some important points of note are:
`#[unstable]` for now.
* All timeout support is removed. This may come back in the form of `setsockopt`
(as with TCP streams) or with a more general implementation of `select`.
* `clone` functionality has been replaced with `duplicate`.
* `clone` functionality has been replaced with `try_clone`.

The `UdpSocket` type will adhere to both `Send` and `Sync`.

Expand Down