Skip to content
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
18 changes: 6 additions & 12 deletions protosocket-rpc/src/client/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,25 +242,19 @@ where
{
log::trace!("new client {address}, {configuration:?}");

let socket = socket2::Socket::new(
match address {
SocketAddr::V4(_) => socket2::Domain::IPV4,
SocketAddr::V6(_) => socket2::Domain::IPV6,
},
socket2::Type::STREAM,
None,
)?;
let stream = TcpStream::connect(&address).await?;

// For setting socket configuration options available to socket2
let socket = socket2::SockRef::from(&stream);

let mut tcp_keepalive = TcpKeepalive::new();
if let Some(duration) = configuration.tcp_keepalive_duration {
tcp_keepalive = tcp_keepalive.with_time(duration);
}

socket.set_nonblocking(true)?;
socket.set_tcp_nodelay(true)?;
socket.set_tcp_keepalive(&tcp_keepalive)?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think this is what this code should do:

    let stream = TcpStream::connect(&address).await?;
    // For setting socket configuration options available to socket2
    let socket = socket2::SockRef::from(&stream);

    let mut tcp_keepalive = TcpKeepalive::new();
    if let Some(duration) = configuration.tcp_keepalive_duration {
        tcp_keepalive = tcp_keepalive.with_time(duration);
    }

    socket.set_nonblocking(true)?;
    socket.set_tcp_nodelay(true)?;
    socket.set_tcp_keepalive(&tcp_keepalive)?;
    socket.set_reuse_address(true)?;

    let message_reactor: RpcCompletionReactor<


let stream = TcpStream::from_std(socket.into())?;
socket.set_tcp_nodelay(true)?;
socket.set_reuse_address(true)?;

let message_reactor: RpcCompletionReactor<
Deserializer::Message,
Expand Down