Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Commit

Permalink
update socket2 to 0.4.0
Browse files Browse the repository at this point in the history
This reverts commit 6643cf9.

Signed-off-by: Marc-Antoine Perennou <[email protected]>
  • Loading branch information
Keruspe committed Mar 16, 2021
1 parent 8cec5f5 commit 5d0efa8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["TcpStream", "UnixStream", "socket2", "polling"]
categories = ["asynchronous", "network-programming", "os"]

[dependencies]
socket2 = { version = "0.3.19", features = ["unix"] }
socket2 = { version = "0.4.0", features = ["all"] }

[target."cfg(unix)".dependencies]
libc = "0.2.77"
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use socket2::{Domain, Protocol, SockAddr, Socket, Type};
use std::{os::unix::net::UnixStream, path::Path};

fn connect(addr: SockAddr, domain: Domain, protocol: Option<Protocol>) -> io::Result<Socket> {
let sock_type = Type::stream();
let sock_type = Type::STREAM;
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
Expand All @@ -53,7 +53,7 @@ fn connect(addr: SockAddr, domain: Domain, protocol: Option<Protocol>) -> io::Re
target_os = "openbsd"
))]
// If we can, set nonblocking at socket creation for unix
let sock_type = sock_type.non_blocking();
let sock_type = sock_type.nonblocking();
// This automatically handles cloexec on unix, no_inherit on windows and nosigpipe on macos
let socket = Socket::new(domain, sock_type, protocol)?;
#[cfg(not(any(
Expand Down Expand Up @@ -108,7 +108,7 @@ fn connect(addr: SockAddr, domain: Domain, protocol: Option<Protocol>) -> io::Re
/// ```
#[cfg(unix)]
pub fn unix<P: AsRef<Path>>(path: P) -> io::Result<UnixStream> {
let socket = connect(SockAddr::unix(path)?, Domain::unix(), None)?;
let socket = connect(SockAddr::unix(path)?, Domain::UNIX, None)?;
Ok(socket.into())
}

Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn unix<P: AsRef<Path>>(path: P) -> io::Result<UnixStream> {
/// ```
pub fn tcp<A: Into<SocketAddr>>(addr: A) -> io::Result<TcpStream> {
let addr = addr.into();
let domain = if addr.is_ipv6() { Domain::ipv6() } else { Domain::ipv4() };
let socket = connect(addr.into(), domain, Some(Protocol::tcp()))?;
let domain = Domain::for_address(addr);
let socket = connect(addr.into(), domain, Some(Protocol::TCP))?;
Ok(socket.into())
}

0 comments on commit 5d0efa8

Please sign in to comment.