Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ serde_with = { version = "3.8.1", default-features = false, features = ["macros"
sha1 = "0.10.0"
sha2 = "0.10.2"
snap = { version = "1.0.5", optional = true }
socket2 = "0.5.5"
stringprep = "0.1.2"
strsim = "0.11.1"
take_mut = "0.2.2"
Expand Down Expand Up @@ -247,6 +246,9 @@ features = ["serde", "serde_json-1"]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true

[target.'cfg(not(wasi))'.dependencies]
socket2 = "0.5.5"

# Target-specific dependencies for GSSAPI authentication
[target.'cfg(not(windows))'.dependencies]
cross-krb5 = { version = "0.4.2", optional = true, default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ async fn tcp_try_connect(address: &SocketAddr) -> Result<TcpStream> {
let stream = TcpStream::connect(address).await?;
stream.set_nodelay(true)?;

let socket = socket2::Socket::from(stream.into_std()?);
#[cfg(not(target_os = "wasi"))]
{
let sock_ref = socket2::SockRef::from(&stream);
let conf = socket2::TcpKeepalive::new().with_time(KEEPALIVE_TIME);
socket.set_tcp_keepalive(&conf)?;
sock_ref.set_tcp_keepalive(&conf)?;
}
let std_stream = std::net::TcpStream::from(socket);
Ok(TcpStream::from_std(std_stream)?)

Ok(stream)
}

pub(crate) async fn tcp_connect(resolved: Vec<SocketAddr>) -> Result<TcpStream> {
Expand Down